CSS बैकग्राउंड-अटैचमेंट प्रॉपर्टी
उदाहरण
एक पृष्ठभूमि-छवि जो पृष्ठ के साथ स्क्रॉल नहीं करेगी (निश्चित):
body {
background-image: url("img_tree.gif");
background-repeat: no-repeat;
background-attachment: fixed;
}
नीचे और अधिक "इसे स्वयं आज़माएं" उदाहरण।
परिभाषा और उपयोग
संपत्ति सेट करती है कि background-attachment
पृष्ठभूमि छवि शेष पृष्ठ के साथ स्क्रॉल करती है या तय की जाती है।
डिफ़ॉल्ट मान: | स्क्रॉल |
---|---|
विरासत में मिला: | नहीं |
एनिमेटेबल: | नहीं। एनिमेटेबल के बारे में पढ़ें |
संस्करण: | सीएसएस 1 |
जावास्क्रिप्ट सिंटैक्स: | ऑब्जेक्ट .style.backgroundअटैचमेंट = "फिक्स्ड" |
ब्राउज़र समर्थन
तालिका में संख्याएं पहले ब्राउज़र संस्करण को निर्दिष्ट करती हैं जो पूरी तरह से संपत्ति का समर्थन करता है।
Property | |||||
---|---|---|---|---|---|
background-attachment | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
सीएसएस सिंटेक्स
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;
}
उदाहरण
एक साधारण लंबन स्क्रॉलिंग प्रभाव कैसे बनाएं (3D गहराई का भ्रम पैदा करें):
.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;
}
संबंधित पृष्ठ
सीएसएस ट्यूटोरियल: सीएसएस पृष्ठभूमि
एचटीएमएल डोम संदर्भ: पृष्ठभूमि अटैचमेंट संपत्ति