margin-right
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 7ì.
* Some parts of this feature may have varying levels of support.
margin-right CSS ìì±ì ììì ì¤ë¥¸ìª½ì ë°ê¹¥ ì¬ë°± ììmargin areaì ì¤ì í©ëë¤. ìì ê°ì ì¸ì ììì 거리를 ëíê³ , ìì ê°ì ë ì¢íëë¤.
ìëí´ ë³´ê¸°
margin-right: 1em;
margin-right: 10%;
margin-right: 10px;
margin-right: 0;
<section id="default-example">
<div id="container">
<div class="col"></div>
<div class="col transition-all" id="example-element"></div>
<div class="col"></div>
</div>
</section>
#container {
width: 300px;
height: 200px;
display: flex;
align-content: flex-start;
justify-content: flex-start;
}
.col {
width: 33.33%;
border: solid #5b6dcd 10px;
background-color: rgba(229, 232, 252, 0.6);
flex-shrink: 0;
}
#example-element {
border: solid 10px #ffc129;
background-color: rgba(255, 244, 219, 0.6);
}
구문
/* <length> ê° */
margin-right: 20px; /* ì ë ê¸¸ì´ */
margin-right: 1em; /* ê¸ì¨ í¬ê¸°ì ìëì */
margin-right: 5%; /* ê°ì¥ ê°ê¹ì´ ë¸ë¡ 컨í
ì´ëì ëë¹ì ìëì */
/* í¤ìë ê° */
margin-right: auto;
/* ì ì ê° */
margin-right: inherit;
margin-right: initial;
margin-right: unset;
margin-right ìì±ì í¤ìë auto, <length>, <percentage>를 ì¬ì©í´ ì¤ì í ì ììµëë¤. ê°ì ìì, 0, ììê° ê°ë¥í©ëë¤.
ê°
<length>-
ë°ê¹¥ ì¬ë°± í¬ê¸°ì ê³ ì ê°.
<percentage>-
ë°ê¹¥ ì¬ë°± í¬ê¸°ì ë¸ë¡ 컨í ì´ë ëë¹ì ë¹ì¨.
auto-
ì¬ì©í ë ì´ìì 모ëì ë°ë¼ ê°ë¡ì¶ 미ì¬ì© ê³µê° ëë¹ì ì¼ë¶ë¥¼ ë°ê¹¥ ì¬ë°±ì í ë¹.
margin-leftìmargin-rightì ê°ì´ 모ëautoë¼ë©´ ëë¹ë¥¼ ì ì¬ë°±ì ëì¼íê² ë°°ì í©ëë¤. ìë íê° ê°ë¥í ì¬ë¬ ê²½ì°ë¥¼ ë³´ì ëë¤.displayê°floatê°positionê°autoì ê³ì° ê°ì¤ëª inline,inline-block,inline-tableany staticorrelative0ì¸ë¼ì¸ ë ì´ìì 모ë block,inline,inline-block,block,table,inline-table,list-item,table-captionany staticorrelative0, except if bothmargin-leftandmargin-rightare set toauto. In this case, it is set to the value centering the element inside its parent.ë¸ë¡ ë ì´ìì 모ë block,inline,inline-block,block,table,inline-table,list-item,table-captionleftorrightstaticorrelative0ë¸ë¡ ë ì´ìì 모ë (íë¡í ìì) any table-*, excepttable-captionany any 0ë´ë¶ table-*ììë ë°ê¹¥ ì¬ë°±ì ê°ì§ì§ ììµëë¤. ëìborder-spacingì ì¬ì©íì¸ì.any, except flex,inline-flex, ortable-*any fixedorabsolute0, except if bothmargin-leftandmargin-rightare set toauto. In this case, it is set to the value centering the border area inside the availablewidth, if fixed.ì ëìì¹ ë ì´ìì 모ë flex,inline-flexany any 0, except if there is any positive horizontal free space. In this case, it is evenly distributed to all horizontalautomargins.íë ì¤ë°ì¤ ë ì´ìì 모ë
íì 구문
margin-right =
<length-percentage> |
auto |
<anchor-size()>
<length-percentage> =
<length> |
<percentage>
<anchor-size()> =
anchor-size( [ <anchor-name> || <anchor-size> ]? , <length-percentage>? )
<anchor-name> =
<dashed-ident>
<anchor-size> =
width |
height |
block |
inline |
self-block |
self-inline
ìì
.content {
margin-right: 5%;
}
.sidebox {
margin-right: 10px;
}
.logo {
margin-right: -5px;
}
ëª ì¸
| Specification |
|---|
| CSS Box Model Module Level 3 > # margin-physical > |
| ì´ê¸°ê° | 0 |
|---|---|
| ì ì©ëì | all elements, except elements with table display types other than table-caption, table and inline-table. It also applies to ::first-letter. |
| ìì | no |
| Percentages | refer to the width of the containing block |
| ê³ì° ê° | the percentage as specified or the absolute length |
| Animation type | a length |