3.1 KiB
3.1 KiB
id | title | required | challengeType | videoUrl | localeTitle | |||||
---|---|---|---|---|---|---|---|---|---|---|
587d7fa5367417b2b2512bbd | Extend One Set of CSS Styles to Another Element |
|
0 |
Description
extend
تجعل من السهل استعارة قواعد CSS من عنصر واحد والبناء عليها في عنصر آخر. على سبيل المثال ، تقوم الكتلة أدناه من قواعد CSS بنمط طبقة .panel
. له background-color
height
border
. .فريق{أنت الآن تريد لوحة أخرى تسمى
لون الخلفية: أحمر.
الارتفاع: 70 بكسل ؛
border: 2px solid green؛
}
.big-panel
. يحتوي على نفس الخصائص الأساسية مثل .panel
، ولكنه يحتاج أيضًا إلى width
وحجم font-size
. من الممكن نسخ قواعد CSS الأولية ولصقها من .panel
، ولكن يصبح الرمز متكررًا عند إضافة المزيد من أنواع اللوحات. على extend
التوجيه هو وسيلة بسيطة لإعادة استخدام قواعد مكتوبة لعنصر واحد، ثم أضيف أكثر لآخر: . كبير لوحة {سيكون
extend .panel؛
العرض: 150 بكسل ؛
حجم الخط: 2em ؛
}
.big-panel
نفس الخصائص مثل .panel
بالإضافة إلى الأنماط الجديدة. Instructions
undefined
Tests
tests:
- text: ''
testString: 'assert(code.match(/\.info-important\s*?{[\s\S]*background-color\s*?:\s*?magenta\s*?;[\s\S]*}/gi), "Your <code>info-important</code> class should have a <code>background-color</code> set to <code>magenta</code>.");'
- text: يجب أن تستخدم فئة <code>info-important</code> الخاصة بك <code>@extend</code> ليرث التصميم من فئة <code>info</code> .
testString: 'assert(code.match(/\.info-important\s*?{[\s\S]*@extend\s*?.info\s*?;[\s\S]*/gi), "Your <code>info-important</code> class should use <code>@extend</code> to inherit the styling from the <code>info</code> class.");'
Challenge Seed
<style type='text/sass'>
h3{
text-align: center;
}
.info{
width: 200px;
border: 1px solid black;
margin: 0 auto;
}
</style>
<h3>Posts</h3>
<div class="info-important">
<p>This is an important post. It should extend the class ".info" and have its own CSS styles.</p>
</div>
<div class="info">
<p>This is a simple post. It has basic styling and can be extended for other uses.</p>
</div>
Solution
// solution required