문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 다음 판 | 이전 판 | ||
|
wiki:css:css_note:css_float-clear [2021/03/15 17:38] emblim98 만듦 |
wiki:css:css_note:css_float-clear [2023/01/13 18:44] (현재) |
||
|---|---|---|---|
| 줄 9: | 줄 9: | ||
| \\ | \\ | ||
| \\ | \\ | ||
| - | =====Source | + | =====The source |
| * [[https:// | * [[https:// | ||
| \\ | \\ | ||
| - | \\ | + | |
| ======The clear Property====== | ======The clear Property====== | ||
| - | '' | + | '' |
| \\ | \\ | ||
| - | '' | + | '' |
| - | * none - 양쪽에 | + | |
| - | * left - 좌측에 플로팅 | + | |
| - | * right - 우측에 플로팅 요소가 허용되지 않습니다. | + | |
| - | * both - 좌측 또는 우측에 플로팅 요소가 허용되지 않습니다. | + | |
| - | * inherit - 요소는 부모의 명확한 값을 상속 받습니다. | + | |
| \\ | \\ | ||
| - | '' | + | '' |
| \\ | \\ | ||
| - | float를 | + | * '' |
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | \\ | ||
| + | %%floats%% 속성을 제거할 | ||
| + | 요소가 좌측으로 | ||
| + | 플로트 | ||
| \\ | \\ | ||
| - | 하기의 예제는 좌측으로의 float를 지웁니다. .div의 좌측에 플로팅 요소가 허용되지 않음을 의미합니다.\\ | ||
| - | ====예제==== | ||
| - | <code html> | ||
| + | ==== Example ==== | ||
| + | 하기의 예제는 좌측으로의 플로트 속성을 제거합니다.\\ | ||
| + | %%< | ||
| + | <code css> | ||
| + | < | ||
| + | .div1 { | ||
| + | float: left; | ||
| + | padding: 10px; | ||
| + | border: 3px solid #73ad21; | ||
| + | } | ||
| + | .div2 { | ||
| + | padding: 10px; | ||
| + | border: 3px solid red; | ||
| + | } | ||
| + | |||
| + | .div3 { | ||
| + | border: 3px solid #72a; | ||
| + | padding: 10px; | ||
| + | float: left; | ||
| + | } | ||
| + | |||
| + | .div4 { | ||
| + | border: 3px solid green; | ||
| + | padding: 10px; | ||
| + | clear: left; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | 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. | ||
| + | </ | ||
| + | <br /><br /> | ||
| + | |||
| + | < | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | div4 - Here, clear: left; moves div4 down below the floating div3. The value " | ||
| + | elements floated to the left. You can also clear " | ||
| + | </ | ||
| + | </ | ||
| </ | </ | ||
| + | ======The clearfix Hack====== | ||
| + | 플로트 된 요소가 플로트 된 요소를 포함하는 요소보다 더 큰 경우, 컨테이너 외부로 __넘치게 됩니다(overflow)__.\\ | ||
| + | 이 문제를 해결하기 위해, clearfix hack을 추가할 수 있습니다.\\ | ||
| + | ====예제==== | ||
| + | <code css> | ||
| + | < | ||
| + | div { | ||
| + | border: 3px solid #4caf50; | ||
| + | padding: 5px; | ||
| + | } | ||
| + | .img1 { | ||
| + | float: right; | ||
| + | } | ||
| + | .img2 { | ||
| + | float: right; | ||
| + | } | ||
| + | |||
| + | .clearfix { | ||
| + | overflow: auto; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | |||
| + | <p> | ||
| + | This image is floated to the right. It is also taller than the element containing it, so it | ||
| + | overflows outside of its container: | ||
| + | </p> | ||
| + | |||
| + | <div> | ||
| + | <img class=" | ||
| + | Lorem ipsum dolor, sit amet consectetur adipisicing elit. Fugit... | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <p> | ||
| + | We can fix this by adding a clearfix class with overflow: auto; to the containing element: | ||
| + | </p> | ||
| + | |||
| + | <div class=" | ||
| + | <img class=" | ||
| + | Lorem ipsum dolor, sit amet consectetur adipisicing elit... | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | \\ | ||
| + | '' | ||
| + | \\ | ||
| + | ==== Example ==== | ||
| + | <code css> | ||
| + | < | ||
| + | div { | ||
| + | border: 3px solid #4caf50; | ||
| + | padding: 5px; | ||
| + | } | ||
| + | |||
| + | .img1 { | ||
| + | float: right; | ||
| + | } | ||
| + | |||
| + | .img2 { | ||
| + | float: right; | ||
| + | } | ||
| + | |||
| + | .clearfix:: | ||
| + | content: ''; | ||
| + | clear: both; | ||
| + | display: table; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | |||
| + | <p> | ||
| + | This image is floated to the right. It is also taller than the element containing it, so it | ||
| + | overflows outside of its container: | ||
| + | </p> | ||
| + | |||
| + | <div> | ||
| + | <img class=" | ||
| + | Lorem ipsum dolor, sit amet consectetur adipisicing elit. Fugit... | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | <div class=" | ||
| + | <img class=" | ||
| + | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt maxime rerum iste error. | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| {{tag> | {{tag> | ||