본문 바로가기

Web Development/HTML & CSS

[CSS] display:flex와 float:right이 함께 적용되지 않을 때 해결방법

728x90
You can't use float inside flex container and the reason is that float property does not apply to flex-level boxes . 
So if you want to position child element to right of parent element you can use margin-left: auto but now child element will also push other div to the right

 

결론: display:flex를 적용했을 때는, float:right 대신 margin-left:auto를 쓰자

 

 

Reference

 

Making a flex item float right

I have a <div class="parent"> <div class="child" style="float:right"> Ignore parent? </div> <div> another child </div> </div> The parent has .parent {...

stackoverflow.com

 

반응형