CSS बैकग्राउंड-रिपीट प्रॉपर्टी
उदाहरण
पृष्ठभूमि-छवि को केवल लंबवत रूप से दोहराएं:
body
{
background-image: url("paper.gif");
background-repeat: repeat-y;
}
नीचे और अधिक "इसे स्वयं आज़माएं" उदाहरण।
परिभाषा और उपयोग
संपत्ति सेट करती है कि background-repeat
पृष्ठभूमि छवि को दोहराया जाएगा या नहीं।
डिफ़ॉल्ट रूप से, पृष्ठभूमि-छवि दोनों लंबवत और क्षैतिज रूप से दोहराई जाती है।
टिप: बैकग्राउंड इमेज को बैकग्राउंड-पोजिशन प्रॉपर्टी के अनुसार रखा जाता है । यदि कोई पृष्ठभूमि-स्थिति निर्दिष्ट नहीं है, तो छवि को हमेशा तत्व के ऊपरी बाएँ कोने में रखा जाता है।
डिफ़ॉल्ट मान: | दोहराना |
---|---|
विरासत में मिला: | नहीं |
एनिमेटेबल: | नहीं। एनिमेटेबल के बारे में पढ़ें |
संस्करण: | सीएसएस 1 |
जावास्क्रिप्ट सिंटैक्स: | ऑब्जेक्ट .style.backgroundRepeat="repeat-x" |
ब्राउज़र समर्थन
तालिका में संख्याएं पहले ब्राउज़र संस्करण को निर्दिष्ट करती हैं जो पूरी तरह से संपत्ति का समर्थन करता है।
Property | |||||
---|---|---|---|---|---|
background-repeat | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
नोट: IE8 और इससे पहले के संस्करण एक तत्व पर एकाधिक पृष्ठभूमि छवियों का समर्थन नहीं करते हैं।
सीएसएस सिंटेक्स
background-repeat: repeat|repeat-x|repeat-y|no-repeat|initial|inherit;
सम्पत्ति की कीमत
Value | Description | Play it |
---|---|---|
repeat | The background image is repeated both vertically and horizontally. The last image will be clipped if it does not fit. This is default | |
repeat-x | The background image is repeated only horizontally | |
repeat-y | The background image is repeated only vertically | |
no-repeat | The background-image is not repeated. The image will only be shown once | |
space | The background-image is repeated as much as possible without clipping. The first and last image is pinned to either side of the element, and whitespace is distributed evenly between the images | |
round | The background-image is repeated and squished or stretched to fill the space (no gaps) | |
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("paper.gif");
background-repeat: repeat;
}
उदाहरण
पृष्ठभूमि छवि को केवल क्षैतिज रूप से दोहराएं:
body
{
background-image: url("paper.gif");
background-repeat: repeat-x;
}
उदाहरण
पृष्ठभूमि छवि को न दोहराएं। छवि केवल एक बार दिखाई जाएगी:
body
{
background-image: url("paper.gif");
background-repeat: no-repeat;
}
उदाहरण
बैकग्राउंड-रिपीट का उपयोग करना: स्पेस और बैकग्राउंड-रिपीट: राउंड:
#example2 {
border: 2px solid black;
padding: 25px;
background: url("w3css.gif");
background-repeat: space;
}
#example3 {
border: 1px solid black;
padding: 25px;
background: url("w3css.gif");
background-repeat: round;
}
उदाहरण
"हीरो" छवि बनाने के लिए विभिन्न पृष्ठभूमि गुणों का उपयोग करें:
.hero-image {
background-image: url("photographer.jpg"); /* The
image used */
background-color: #cccccc; /* Used if the image is
unavailable */
height: 500px; /* You must set a specified height */
background-position: center; /* Center the image */
background-repeat: no-repeat; /* Do not repeat the image */
background-size: cover; /* Resize the background image to cover the entire container */
}
संबंधित पृष्ठ
सीएसएस ट्यूटोरियल: सीएसएस पृष्ठभूमि
सीएसएस संदर्भ: पृष्ठभूमि-स्थिति संपत्ति
एचटीएमएल डोम संदर्भ: पृष्ठभूमि संपत्ति दोहराएं