CSS ऑब्जेक्ट-फिट प्रॉपर्टी
उदाहरण
एक छवि के किनारों को काटें, पहलू अनुपात को बनाए रखें, और स्थान भरें:
img.a {
width: 200px;
height:
400px;
object-fit: cover;
}
परिभाषा और उपयोग
संपत्ति का उपयोग यह object-fit
निर्दिष्ट करने के लिए किया जाता है कि कैसे एक <img> या <video> को उसके कंटेनर में फिट करने के लिए आकार दिया जाना चाहिए।
यह गुण सामग्री को कंटेनर को विभिन्न तरीकों से भरने के लिए कहता है; जैसे "उस पहलू अनुपात को सुरक्षित रखें" या "खिंचाव बढ़ाएं और जितना संभव हो उतना स्थान लें"।
डिफ़ॉल्ट मान: | व्यक्तिगत गुण देखें |
---|---|
विरासत में मिला: | नहीं |
एनिमेटेबल: | नहीं। एनिमेटेबल के बारे में पढ़ें |
संस्करण: | CSS3 |
जावास्क्रिप्ट सिंटैक्स: | ऑब्जेक्ट .style.objectFit = "कवर" |
ब्राउज़र समर्थन
तालिका में संख्याएं पहले ब्राउज़र संस्करण को निर्दिष्ट करती हैं जो पूरी तरह से संपत्ति का समर्थन करता है।
Property | |||||
---|---|---|---|---|---|
object-fit | 31.0 | 16.0 | 36.0 | 7.1 | 19.0 |
सीएसएस सिंटेक्स
object-fit: fill|contain|cover|scale-down|none|initial|inherit;
सम्पत्ति की कीमत
Value | Description | Try it |
---|---|---|
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 |
संबंधित पृष्ठ
CSS ट्यूटोरियल: CSS ऑब्जेक्ट-फिट
CSS संदर्भ: CSS वस्तु-स्थिति
एचटीएमएल डोम संदर्भ: ऑब्जेक्टफिट संपत्ति