[CSS] flex 안에 있는 요소 우측정렬

2020. 3. 5. 21:05
반응형

 

1
2
3
4
<div class="parent">
  <div class="left">one</div>
  <div class="right">two</div>
</div>
 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
.parent{
  display:flex;
  width:500px;
  height:50px;
  border:1px solid black;
  align-items: center;
  background-color:yellowgreen;
}
 
.left, .right{
  background-color:yellow;
  margin: 0 1rem;
}
 
.right{
  margin-left:auto;
}
 

 

margin-left : auto; 를 써주면 오른쪽 정렬된다.

 

*결과물

 


 

 

 

 

 

https://codepen.io/dayoung0510/pen/wvarpav

 

flex 안 자식요소들 좌측/우측 정렬

...

codepen.io

 

반응형

BELATED ARTICLES

more