स्टाइल ऑब्जेक्टफ़िट प्रॉपर्टी
उदाहरण
एक छवि के किनारों को काटें, पहलू अनुपात को बनाए रखें, और स्थान भरें:
document.getElementById("myImg").style.objectFit = "cover";
परिभाषा और उपयोग
ObjectFit गुण का उपयोग यह निर्दिष्ट करने के लिए किया जाता है कि कैसे एक <img> या <video> को उसके कंटेनर में फिट करने के लिए आकार दिया जाना चाहिए।
यह गुण सामग्री को कंटेनर को विभिन्न तरीकों से भरने के लिए कहता है; जैसे "उस पहलू अनुपात को सुरक्षित रखें" या "खिंचाव बढ़ाएं और जितना संभव हो उतना स्थान लें"
ब्राउज़र समर्थन
तालिका में संख्याएं पहले ब्राउज़र संस्करण को निर्दिष्ट करती हैं जो पूरी तरह से संपत्ति का समर्थन करता है।
Property | |||||
---|---|---|---|---|---|
objectFit | 31.0 | 16.0 | 36.0 | 7.1 | 19.0 |
वाक्य - विन्यास
ऑब्जेक्टफिट संपत्ति लौटाएं:
object.style.objectFit
ऑब्जेक्ट फ़िट गुण सेट करें:
object.style.objectFit = "fill|contain|cover|scale-down|none|initial|inherit"
सम्पत्ति की कीमत
Value | Description |
---|---|
fill | This is default. The replaced content is sized to fill the element's content box. If necessary, the object will be stretched or squished to fit |
contain | The replaced content is scaled to maintain its aspect ratio while fitting within the element's content box |
cover | The replaced content is sized to maintain its aspect ratio while filling the element's entire content box. The object will be clipped to fit |
none | The replaced content is not resized |
scale-down | The content is sized as if none or contain were specified (would result in a smaller concrete object size) |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
टेक्निकल डिटेल
डिफ़ॉल्ट मान: | भरना |
---|---|
प्रतिलाभ की मात्रा: | एक स्ट्रिंग, एक तत्व के वस्तु-फिट का प्रतिनिधित्व करता है |
सीएसएस संस्करण | CSS3 |
संबंधित पृष्ठ
CSS ट्यूटोरियल: CSS ऑब्जेक्ट-फिट
CSS संदर्भ: वस्तु-फिट गुण
❮ स्टाइल ऑब्जेक्ट