Without clear
div1
div2 - Notice that div2 is after div1 in the HTML code. However, since div1 floats to the
left, the text in div2 flows around div1.
With clear
div3
div4 - Here, clear: left; moves div4 down below the floating div3. The value "left" clears
elements floated to the left. You can also clear "right" and "both".
======The clearfix Hack======
플로트 된 요소가 플로트 된 요소를 포함하는 요소보다 더 큰 경우, 컨테이너 외부로 __넘치게 됩니다(overflow)__.\\
이 문제를 해결하기 위해, clearfix hack을 추가할 수 있습니다.\\
====예제====
Without Clearfix
This image is floated to the right. It is also taller than the element containing it, so it
overflows outside of its container:
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Fugit...
With Clearfix
We can fix this by adding a clearfix class with overflow: auto; to the containing element:
Lorem ipsum dolor, sit amet consectetur adipisicing elit...
\\
''overflow: auto'' clearfix는 마진과 패딩을 제어할 수 있는 한 잘 작동합니다.(그렇지 않을 경우, 스크롤 막대가 표시될 수 있슴). 그러나 새롭고 현대적인 clearfix hack은 사용하기에 더 안전하며, 대부분의 웹페이지에서 아래의 코드가 사용됩니다.\\
\\
==== Example ====
Without Clearfix
This image is floated to the right. It is also taller than the element containing it, so it
overflows outside of its container:
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Fugit...
With New Modern Clearfix
Add the clearfix hack to the containing element, to fix this problem:
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt maxime rerum iste error.
{{tag>오션, CSS float, clear }}