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
بالإضافة إلى الأنماط الجديدة. info-important
class should have a background-color
set to magenta
.");'
- text: يجب أن تستخدم فئة info-important
الخاصة بك @extend
ليرث التصميم من فئة info
.
testString: 'assert(code.match(/\.info-important\s*?{[\s\S]*@extend\s*?.info\s*?;[\s\S]*/gi), "Your info-important
class should use @extend
to inherit the styling from the info
class.");'
```
This is an important post. It should extend the class ".info" and have its own CSS styles.
This is a simple post. It has basic styling and can be extended for other uses.