शैली पृष्ठभूमिस्थिति संपत्ति
उदाहरण
पृष्ठभूमि-छवि की स्थिति बदलें:
document.body.style.backgroundPosition = "top right";
नीचे और अधिक "इसे स्वयं आज़माएं" उदाहरण।
परिभाषा और उपयोग
बैकग्राउंडपोजिशन प्रॉपर्टी किसी तत्व के भीतर बैकग्राउंड-इमेज की स्थिति सेट या लौटाती है।
ब्राउज़र समर्थन
तालिका में संख्याएं पहले ब्राउज़र संस्करण को निर्दिष्ट करती हैं जो पूरी तरह से संपत्ति का समर्थन करता है।
Property | |||||
---|---|---|---|---|---|
backgroundPosition | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
वाक्य - विन्यास
पृष्ठभूमि स्थिति संपत्ति लौटाएं:
object.style.backgroundPosition
पृष्ठभूमि स्थिति गुण सेट करें:
object.style.backgroundPosition = value
सम्पत्ति की कीमत
Value | Description |
---|---|
top left top center top right center left center center center right bottom left bottom center bottom right |
If you only specify one keyword, the other value will be "center". |
x% y% | The x value indicates the horizontal position and the y value indicates the vertical position. 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%. |
xpos ypos | The x value indicates the horizontal position and the y value indicates the vertical position. 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 units |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
टेक्निकल डिटेल
डिफ़ॉल्ट मान: | 0% 0% |
---|---|
प्रतिलाभ की मात्रा: | पृष्ठभूमि-छवि की स्थिति का प्रतिनिधित्व करने वाला एक स्ट्रिंग |
सीएसएस संस्करण | सीएसएस 1 |
और ज्यादा उदाहरण
उदाहरण
बैकग्राउंड-इमेज की स्थिति को <div> एलिमेंट में सेंटर बॉटम में बदलें:
document.getElementById("myDiv").style.backgroundPosition = "center bottom";
उदाहरण
पृष्ठभूमि-छवि की स्थिति को <div> तत्व में 200px क्षैतिज और 40px लंबवत में बदलें:
document.getElementById("myDiv").style.backgroundPosition = "200px 40px";
उदाहरण
एक <div> तत्व में पृष्ठभूमि-छवि की स्थिति लौटाएं:
document.getElementById("myDiv").style.backgroundPosition;
संबंधित पृष्ठ
सीएसएस ट्यूटोरियल: सीएसएस पृष्ठभूमि
सीएसएस संदर्भ: पृष्ठभूमि-छवि संपत्ति
सीएसएस संदर्भ: पृष्ठभूमि-स्थिति संपत्ति
एचटीएमएल डोम संदर्भ: पृष्ठभूमि संपत्ति