object-position
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2020ë 1ì.
CSS object-position ìì±ì ëì²´ ììì ì½í
ì¸ ì ë ¬ ë°©ìì ì§ì í©ëë¤. ëì²´ ììì ê°ì²´ê° ë®ì§ ìì ë¶ë¶ì ììì ë°°ê²½ì´ ë³´ì´ê² ë©ëë¤.
ëì²´ ìì ê°ì²´ì ê³ ì í¬ê¸°(ìì ì ê°íì§ ìì ìë í¬ê¸°)를 ì¡°ì í´ ìì ë°ì¤ì ë§ì¶ë ë°©ë²ì object-fit ìì±ì¼ë¡ ì§ì í ì ììµëë¤.
ìëí´ ë³´ê¸°
object-position: 50% 50%;
object-position: right top;
object-position: left bottom;
object-position: 250px 125px;
<section id="default-example">
<img
class="transition-all"
id="example-element"
src="/proxy/developer.mozilla.org/shared-assets/images/examples/moon.jpg" />
</section>
#example-element {
height: 250px;
width: 250px;
object-fit: none;
border: 1px solid red;
}
구문
/* <position> ê° */
object-position: center top;
object-position: 100px 50px;
/* ì ì ê° */
object-position: inherit;
object-position: initial;
object-position: unset;
ê°
<position>-
ê°ì²´ì 2D ìì¹ë¥¼ ì§ì íë í ê°ìì ë¤ ê°ì ê°. ìëì ì ë ì¤íì ì ì¬ì©í ì ììµëë¤.
ì°¸ê³ : ì½í ì¸ ê° ëì²´ ììì ë°ì¤ ë°ê¹¥ì¼ë¡ ëê°ëë¡ ì§ì í ìë ììµëë¤.
íì ì ì
| ì´ê¸°ê° | 50% 50% |
|---|---|
| ì ì©ëì | replaced elements |
| ìì | yes |
| Percentages | refer to width and height of element itself |
| ê³ì° ê° | as specified |
| Animation type | a repeatable list |
íì 구문
object-position =
<position>
<position> =
<position-one> |
<position-two> |
<position-four>
<position-one> =
left |
center |
right |
top |
bottom |
x-start |
x-end |
y-start |
y-end |
block-start |
block-end |
inline-start |
inline-end |
<length-percentage>
<position-two> =
[ left | center | right | x-start | x-end ] && [ top | center | bottom | y-start | y-end ] |
[ left | center | right | x-start | x-end | <length-percentage> ] [ top | center | bottom | y-start | y-end | <length-percentage> ] |
[ block-start | center | block-end ] && [ inline-start | center | inline-end ] |
[ start | center | end ]{2}
<position-four> =
[ [ left | right | x-start | x-end ] <length-percentage> ] && [ [ top | bottom | y-start | y-end ] <length-percentage> ] |
[ [ block-start | block-end ] <length-percentage> ] && [ [ inline-start | inline-end ] <length-percentage> ] |
[ [ start | end ] <length-percentage> ]{2}
<length-percentage> =
<length> |
<percentage>
ìì
>ì´ë¯¸ì§ ì½í ì¸ ìì¹ ì§ì
HTML
ë ê°ì <img> ììê° MDN ë¡ê³ 를 ê°ë¦¬í¤ë ì½ëì
ëë¤.
<img id="object-position-1" src="mdn.svg" alt="MDN Logo" />
<img id="object-position-2" src="mdn.svg" alt="MDN Logo" />
CSS
ë¤ì CSSë ë <img> ìì 모ëì ì ì©í ì¤íì¼ê³¼ í¨ê», ê°ê° ë³ëë¡ ì ì©í object-position ìì±ë ì§ì íê³ ììµëë¤.
img {
width: 300px;
height: 250px;
border: 1px solid black;
background-color: silver;
margin-right: 1em;
object-fit: none;
}
#object-position-1 {
object-position: 10px;
}
#object-position-2 {
object-position: 100% 10%;
}
첫 ë²ì§¸ ì´ë¯¸ì§ë ìì ë°ì¤ì ì¼ìª½ ê²½ê³ë¡ë¶í° 10í½ì ë¨ì´ì§ ê³³ì¼ë¡ ë°°ì¹ë©ëë¤. ë ë²ì§¸ ì´ë¯¸ì§ë ìì ë°ì¤ì ì¤ë¥¸ìª½ ê²½ê³ì ìì ì ì¤ë¥¸ìª½ 모ì리를 ìë¡ ê²¹ì¹ê³ , ë°ì¤ì ì쪽 ê²½ê³ë¡ë¶í° ë°ì¤ ëì´ì 10% ë¨ì´ì§ ì§ì ì¼ë¡ ë°°ì¹ë©ëë¤.
ê²°ê³¼
ëª ì¸
| Specification |
|---|
| CSS Images Module Level 3> # the-object-position> |
ë¸ë¼ì°ì í¸íì±
ê°ì´ 보기
- ì´ë¯¸ì§ ê´ë ¨ ë¤ë¥¸ CSS ìì±:
object-fit,image-orientation,image-rendering,image-resolution.