خاصية خط النمط
مثال
عيّن الخط لعنصر:
document.getElementById("demo").style.font = "italic bold 20px arial,serif";
التعريف والاستخدام
تقوم خاصية الخط بتعيين أو إرجاع ما يصل إلى ست خصائص خط منفصلة ، في نموذج مختصر.
باستخدام هذه الخاصية ، يمكنك تعيين / إرجاع ما يلي (بهذا الترتيب):
- نوع الخط
- متغير الخط
- وزن الخط
- حجم الخط
- ارتفاع خط
- خط العائلة
حجم الخط ومجموعة الخطوط مطلوبان. إذا كانت إحدى القيم الأخرى مفقودة ، فسيتم إدراج القيم الافتراضية ، إن وجدت.
يمكن أيضًا تعيين الخصائص المذكورة أعلاه بخصائص نمط منفصلة. يوصى بشدة باستخدام خصائص منفصلة للمؤلفين غير المتقدمين لتحسين إمكانية التحكم.
دعم المتصفح
Property | |||||
---|---|---|---|---|---|
font | Yes | Yes | Yes | Yes | Yes |
بناء الجملة
إرجاع خاصية الخط:
object.style.font
قم بتعيين خاصية الخط:
object.style.font = "font-style font-variant font-weight font-size/line-height|caption|icon|menu|
message-box|small-caption|status-bar|initial|inherit;"
قيم الملكية
Value | Description |
---|---|
style | Sets the font-style |
variant | Sets the text in a small-caps font |
weight | Sets the boldness of the font |
size | Sets the size of the font |
lineHeight | Sets the distance between lines |
family | Sets the font face |
caption | The font used for captioned controls (like buttons, drop-downs, etc.) |
icon | The font used to label icons |
menu | The font used in menus |
message-box | The font used in dialog boxes |
small-caption | The font used in small controls |
status-bar | The font used in window status bars |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
تفاصيل تقنية
القيمة الافتراضية: | غير محدد |
---|---|
قيمة الإرجاع: | سلسلة ، تمثل خصائص خط مختلفة للعنصر |
إصدار CSS | CSS1 |
مزيد من الأمثلة
مثال
إرجاع خط عنصر:
alert(document.getElementById("demo").style.font);
الصفحات ذات الصلة
برنامج CSS التعليمي: CSS Font
مرجع CSS: خاصية الخط
❮ نمط الكائن