Меню
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP КАК СДЕЛАТЬ ПРОГРАММЫ SW3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS КИБЕРБЕЗОПАСНОСТЬ НАУКА О ДАННЫХ
     ❯   

CSS Справочники


CSS Свойства





object-fit


Example

Cut off the sides of an image, preserving the aspect ratio, and fill in the space:

img.a {
  width: 200px;
  height: 400px;
  object-fit: cover;
}
Try it Yourself »

Definition object-fit

The object-fit property is used to specify how an <img> or <video> should be resized to fit its container.

This property tells the content to fill the container in a variety of ways; such as "preserve that aspect ratio" or "stretch up and take up as much space as possible".

Show demo ❯

Default value: see individual properties
Inherited: no
Animatable: no. Read about animatable
Version: CSS3
JavaScript syntax: object.style.objectFit="cover" Try it

Browser Support object-fit

The numbers in the table specify the first browser version that fully supports the property.

Property
object-fit 31.0 16.0 36.0 7.1 19.0


CSS Syntax object-fit

object-fit: fill|contain|cover|scale-down|none|initial|inherit;

Property Values object-fit

Value Description Demo
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 Demo ❯
contain The replaced content is scaled to maintain its aspect ratio while fitting within the element's content box Demo ❯
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 Demo ❯
none The replaced content is not resized Demo ❯
scale-down The content is sized as if none or contain were specified (would result in a smaller concrete object size) Demo ❯
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

Related Pages object-fit

CSS tutorial: CSS object-fit

CSS reference: CSS object-position

HTML DOM reference: The objectFit property



×

Связаться с отделом продаж

Если вы хотите использовать услуги schoolsw3 как образовательное учреждение, команда или предприятие, отправьте нам электронное письмо:
sales@schoolsw3.com

Сообщить об ошибке

Если вы хотите сообщить об ошибке или внести предложение, отправьте нам электронное письмо:
help@schoolsw3.com

Schoolsw3 оптимизирован для обучения и подготовки. Примеры могут быть упрощены для улучшения чтения и обучения. Учебники, ссылки и примеры постоянно проверяются, чтобы избежать ошибок, но мы не можем гарантировать полную правильность всего контента.
При использовании Schoolsw3 вы соглашаетесь прочитать и принять наши условия использования,
политику использования файлов cookie и конфиденциальности.

Авторское право 1999- принадлежит Refsnes Data. Все права защищены. Schoolsw3 работает на SW3.CSS.