خاصية شبكة CSS
مثال
قم بعمل تخطيط شبكي من ثلاثة أعمدة حيث يبلغ ارتفاع الصف الأول 150 بكسل:
.grid-container {
display: grid;
grid: 150px
/ auto auto auto;
}
التعريف والاستخدام
الخاصية هي grid
خاصية مختصرة من أجل:
- شبكة قالب الصفوف
- شبكة-قالب-أعمدة
- مناطق قالب الشبكة
- صفوف الشبكة السيارات
- شبكة الأعمدة الآلية
- شبكة التدفق التلقائي
القيمة الافتراضية: | لا شيء لا شيء السيارات الصف |
---|---|
وارث: | رقم |
متحرك: | نعم ، انظر الخصائص الفردية . اقرأ عن animatable |
الإصدار: | وحدة تخطيط شبكة CSS المستوى 1 |
بناء جملة JavaScript: | الكائن .style.grid = "250px / auto auto" |
دعم المتصفح
تحدد الأرقام الواردة في الجدول إصدار المتصفح الأول الذي يدعم الخاصية بالكامل.
Property | |||||
---|---|---|---|---|---|
grid | 57 | 16 | 52 | 10 | 44 |
بنية CSS
grid: none|grid-template-rows /
grid-template-columns|grid-template-areas|grid-template-rows
/ [grid-auto-flow] grid-auto-columns|[grid-auto-flow] grid-auto-rows / grid-template-columns|initial|inherit;
قيم الملكية
Value | Description | Play it |
---|---|---|
none | Default value. No specific sizing of the columns or rows | |
grid-template-rows / grid-template-columns | Specifies the size(s) of the columns and rows | |
grid-template-areas | Specifies the grid layout using named items | |
grid-template-rows / grid-auto-columns | Specifies the size (height) of the rows, and the auto size of the columns | |
grid-auto-rows / grid-template-columns | Specifies the auto size of the rows, and sets the grid-template-columns property | |
grid-template-rows / grid-auto-flow grid-auto-columns | Specifies the size (height) of the rows, and how to place auto-placed items, and the auto size of the columns | |
grid-auto-flow grid-auto-rows / grid-template-columns | Specifies how to place auto-placed items, and the auto size of the rows, and sets the grid-template-columns property | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
مزيد من الأمثلة
مثال
حدد صفين ، حيث يمتد "العنصر 1" على أول عمودين في أول صفين (في تخطيط شبكة بخمسة أعمدة):
.item1 {
grid-area: myArea;
}
.grid-container {
display: grid;
grid:
'myArea myArea . . .'
'myArea myArea . . .';
}
مثال
قم بتسمية جميع العناصر ، وقم بإنشاء قالب صفحة ويب جاهز للاستخدام:
.item1 { grid-area: header; }
.item2 { grid-area:
menu; }
.item3 { grid-area:
main; }
.item4 { grid-area:
right; }
.item5 { grid-area:
footer; }
.grid-container {
display: grid;
grid:
'header header header header header'
'menu main main main right right'
'menu footer footer
footer footer';
}
الصفحات ذات الصلة
دروس CSS: CSS Grid Container
مرجع CSS: خاصية مناطق قالب الشبكة
مرجع CSS: خاصية Grid-template-rows
مرجع CSS: خاصية الشبكة - قالب - أعمدة
مرجع CSS: خاصية الشبكة - auto-rows
مرجع CSS: خاصية أعمدة الشبكة التلقائية
مرجع CSS: خاصية Grid-auto-flow
مرجع CSS: خاصية الشبكة-الصف-الفجوة
مرجع CSS: خاصية الشبكة - العمود - الفجوة