CSS object-position Property
Example
.example {
width: 200px;
height: 100px;
object-fit: cover;
object-position: 10px 10px;
border: 3px solid black;
}
Meaning
The object-position property specifies the alignment of the selected replaced element's contents within the element's box.
Areas of the box which aren't covered by the replaced element's object will show the element's background.
You can adjust how the replaced element's object's intrinsic size (that is, its natural size) is adjusted to fit within the element's box using the object-fit property.
Default value: | 50% 50% |
Inherited: | Yes |
Animatable: | Yes |
Version: | CSS3 |
JavaScript syntax: |
|
Standard Syntax
object-position: position|initial|inherit|revert|revert-layer|unset;
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Status
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
position | Specifies the position of the image or video inside its content box.
|
initial | Sets this property to its default value. |
inherit | If specified, the associated element takes the computed value of its parent element animation-delay property. |
revert | Reverts the cascaded value of the property from its current value to the value the property |
revert-layer | Rollback styles to the ones specified in previous cascade layers. |
unset | Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not. |
Default CSS Property Values
selectors {
object-position: 50% 50%;
}
More Examples
The following example use percentage value:
object-position: 10% 100%;
Example
.example {
width: 200px;
height: 300px;
object-fit: cover;
object-position: 10% 100%;
border: 3px solid black;
}
The following example use percentage value:
object-position: -100px 0;
Example
.example {
width: 200px;
height: 300px;
object-fit: cover;
object-position: -100px 0;
border: 3px solid black;
}