सीएसएस पृष्ठभूमि-स्थिति संपत्ति
उदाहरण
पृष्ठभूमि-छवि को कैसे स्थापित करें:
body
{
background-image: url('w3css.gif');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
नीचे और अधिक "इसे स्वयं आज़माएं" उदाहरण।
परिभाषा और उपयोग
संपत्ति पृष्ठभूमि छवि की background-position
प्रारंभिक स्थिति निर्धारित करती है।
युक्ति: डिफ़ॉल्ट रूप से, एक पृष्ठभूमि-छवि एक तत्व के ऊपरी-बाएँ कोने में रखी जाती है, और लंबवत और क्षैतिज दोनों तरह से दोहराई जाती है।
डिफ़ॉल्ट मान: | 0% 0% |
---|---|
विरासत में मिला: | नहीं |
एनिमेटेबल: | हां। एनिमेटेबल के बारे में पढ़ें |
संस्करण: | सीएसएस 1 |
जावास्क्रिप्ट सिंटैक्स: | ऑब्जेक्ट .style.backgroundPosition = "center" |
ब्राउज़र समर्थन
तालिका में संख्याएं पहले ब्राउज़र संस्करण को निर्दिष्ट करती हैं जो पूरी तरह से संपत्ति का समर्थन करता है।
Property | |||||
---|---|---|---|---|---|
background-position | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
नोट: IE8 और इससे पहले के संस्करण एक तत्व पर एकाधिक पृष्ठभूमि छवियों का समर्थन नहीं करते हैं।
सीएसएस सिंटेक्स
background-position: value;
सम्पत्ति की कीमत
Value | Description | Play it |
---|---|---|
left top left center left bottom right top right center right bottom center top center center center bottom |
If you only specify one keyword, the other value will be "center" | |
x% y% | The first value is the horizontal position and the second value is the vertical. The top left corner is 0% 0%. The right bottom corner is 100% 100%. If you only specify one value, the other value will be 50%. Default value is: 0% 0% | |
xpos ypos | The first value is the horizontal position and the second value is the vertical. The top left corner is 0 0. Units can be pixels (0px 0px) or any other CSS units. If you only specify one value, the other value will be 50%. You can mix % and positions | |
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('w3css.gif');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center top;
}
उदाहरण
पृष्ठभूमि-छवि को नीचे दाईं ओर कैसे रखें:
body
{
background-image: url('w3css.gif');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: bottom right;
}
उदाहरण
प्रतिशत का उपयोग करके पृष्ठभूमि-छवि को कैसे स्थापित करें:
body
{
background-image: url('w3css.gif');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: 50% 50%;
}
उदाहरण
पिक्सल का उपयोग करके पृष्ठभूमि-छवि को कैसे स्थापित करें:
body
{
background-image: url('w3css.gif');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: 50px 150px;
}
उदाहरण
"हीरो" छवि बनाने के लिए विभिन्न पृष्ठभूमि गुणों का उपयोग करें:
.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 */
}
संबंधित पृष्ठ
सीएसएस ट्यूटोरियल: सीएसएस पृष्ठभूमि
सीएसएस संदर्भ: पृष्ठभूमि-छवि संपत्ति
एचटीएमएल डोम संदर्भ: पृष्ठभूमि स्थिति संपत्ति