Stil nesnesiFit Özellik
Örnek
En-boy oranını koruyarak görüntünün kenarlarını kesin ve boşluğu doldurun:
document.getElementById("myImg").style.objectFit = "cover";
Tanım ve Kullanım
objectFit özelliği, bir <img> veya <video> öğesinin kapsayıcısına sığdırmak için nasıl yeniden boyutlandırılması gerektiğini belirtmek için kullanılır.
Bu özellik, içeriğe kapsayıcıyı çeşitli şekillerde doldurmasını söyler; "Bu en boy oranını koru" veya "gerin ve mümkün olduğunca fazla yer kaplayın" gibi
Tarayıcı Desteği
Tablodaki sayılar, özelliği tam olarak destekleyen ilk tarayıcı sürümünü belirtir.
Property | |||||
---|---|---|---|---|---|
objectFit | 31.0 | 16.0 | 36.0 | 7.1 | 19.0 |
Sözdizimi
objectFit özelliğini döndürün:
object.style.objectFit
objectFit özelliğini ayarlayın:
object.style.objectFit = "fill|contain|cover|scale-down|none|initial|inherit"
Mülk değerleri
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 |
Teknik detaylar
Varsayılan değer: | doldurmak |
---|---|
Geri dönüş değeri: | Bir öğenin nesne uyumunu temsil eden bir Dize |
CSS Sürümü | CSS3 |
İlgili Sayfalar
CSS eğitimi: CSS nesne uyumu
CSS referansı: nesneye sığdırma özelliği
❮ Stil Nesnesi