خاصية مرفقات الخلفية في CSS
مثال
صورة الخلفية التي لن يتم تمريرها مع الصفحة (تم التصحيح):
body {
background-image: url("img_tree.gif");
background-repeat: no-repeat;
background-attachment: fixed;
}
المزيد من الأمثلة "جربها بنفسك" أدناه.
التعريف والاستخدام
تحدد الخاصية ما background-attachment
إذا كانت صورة الخلفية يتم تمريرها مع بقية الصفحة أم أنها ثابتة.
القيمة الافتراضية: | التمرير |
---|---|
وارث: | رقم |
متحرك: | رقم. اقرأ عن animatable |
الإصدار: | CSS1 |
بناء جملة JavaScript: | الكائن .style.backgroundAttachment = "ثابت" |
دعم المتصفح
تحدد الأرقام الواردة في الجدول إصدار المتصفح الأول الذي يدعم الخاصية بالكامل.
Property | |||||
---|---|---|---|---|---|
background-attachment | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
بنية CSS
background-attachment: scroll|fixed|local|initial|inherit;
قيم الملكية
Value | Description |
---|---|
scroll | The background image will scroll with the page. This is default |
fixed | The background image will not scroll with the page |
local | The background image will scroll with the element's contents |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
مزيد من الأمثلة
مثال
صورة الخلفية التي سيتم تمريرها مع الصفحة (التمرير). هذا هو الافتراضي:
body {
background-image: url("img_tree.gif");
background-repeat: no-repeat;
background-attachment: scroll;
}
مثال
كيفية إنشاء تأثير تمرير المنظر البسيط (إنشاء وهم بعمق ثلاثي الأبعاد):
.fixed-bg {
/* The background image */
background-image: url("img_tree.gif");
/* Set a specified height, or the minimum height for the background image */
min-height: 500px;
/* Set background image to fixed (don't scroll along with the page) */
background-attachment: fixed;
/* Center the background image */
background-position: center;
/* Set the background image to no repeat */
background-repeat: no-repeat;
/* Scale the background image to be as large as possible */
background-size: cover;
}
الصفحات ذات الصلة
دروس CSS: خلفية CSS
مرجع DOM HTML: خاصية backgroundAttachment