문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
wiki:css:css_note:css_float-clear [2021/07/26 14:42] emblim98 [Source of the article] |
wiki:css:css_note:css_float-clear [2023/01/13 18:44] (현재) |
||
|---|---|---|---|
| 줄 14: | 줄 14: | ||
| ======The clear Property====== | ======The clear Property====== | ||
| - | '' | + | '' |
| \\ | \\ | ||
| - | '' | + | '' |
| - | * none - 양쪽에 | + | |
| - | * left - 좌측에 플로팅 | + | |
| - | * right - 우측에 플로팅 요소가 허용되지 않습니다. | + | |
| - | * both - 좌측 또는 우측에 플로팅 요소가 허용되지 않습니다. | + | |
| - | * inherit - 요소는 부모의 명확한 값을 상속 받습니다. | + | |
| \\ | \\ | ||
| - | '' | + | '' |
| \\ | \\ | ||
| - | float를 | + | * '' |
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | \\ | ||
| + | %%floats%% 속성을 제거할 | ||
| + | 요소가 좌측으로 | ||
| + | 플로트 | ||
| \\ | \\ | ||
| - | 하기의 예제는 좌측으로의 float를 지웁니다. .div의 좌측에 플로팅 요소가 허용되지 않음을 의미합니다.\\ | ||
| - | ====예제==== | ||
| - | <code html> | ||
| - | < | ||
| - | <html lang=" | ||
| - | < | + | ==== Example |
| - | <meta charset=" | + | 하기의 예제는 좌측으로의 플로트 속성을 제거합니다.\\ |
| - | <meta http-equiv=" | + | %%<div2>%% 요소가 좌측으로 플로트 된 %%<div1>%% 요소 아래에 위치된다는 것을 의미합니다.\\ |
| - | <meta name=" | + | <code css> |
| - | <title>Without/ | + | < |
| - | < | + | .div1 { |
| - | .div1 { | + | float: left; |
| - | float: left; | + | |
| - | | + | border: 3px solid #73ad21; |
| - | height: 50px; | + | } |
| - | margin: 10px; | + | |
| - | border: 3px solid green; | + | |
| - | } | + | |
| - | | + | |
| - | border: | + | |
| - | } | + | |
| + | } | ||
| - | | + | |
| - | float: left; | + | |
| - | | + | |
| - | height: 50px; | + | float: left; |
| - | margin: 10px; | + | } |
| - | | + | |
| - | } | + | |
| - | | + | |
| - | border: | + | border: |
| - | clear: left; | + | |
| - | } | + | |
| + | } | ||
| </ | </ | ||
| - | </ | + | |
| - | + | < | |
| - | < | + | |
| < | < | ||
| - | <div class=" | + | <div class=" |
| <div class=" | <div class=" | ||
| - | < | + | |
| - | | + | |
| - | | + | |
| </ | </ | ||
| - | < | + | < |
| < | < | ||
| - | <div class=" | + | <div class=" |
| - | <div class=" | + | <div class=" |
| - | | + | |
| + | | ||
| </ | </ | ||
| - | </ | + | |
| + | </ | ||
| + | |||
| + | ======The clearfix Hack====== | ||
| + | 플로트 된 요소가 플로트 된 요소를 포함하는 요소보다 더 큰 경우, 컨테이너 외부로 __넘치게 됩니다(overflow)__.\\ | ||
| + | 이 문제를 해결하기 위해, clearfix hack을 추가할 수 있습니다.\\ | ||
| - | </ | ||
| - | </ | ||
| - | \\ | ||
| - | \\ | ||
| - | =====The clearfix Hack===== | ||
| - | 어떤 한 요소가 자신을 포함하고 있는 요소보다 크고 float된 경우, 컨테이너 외부로 넘치게 됩니다.\\ | ||
| - | 그리고 나서, 이 문제를 해결하기 위해, 요소를 포함하는 것에 '' | ||
| ====예제==== | ====예제==== | ||
| - | < | + | < |
| - | <!DOCTYPE html> | + | <style> |
| - | <html lang=" | + | div { |
| + | border: 3px solid #4caf50; | ||
| + | padding: 5px; | ||
| + | } | ||
| - | < | + | |
| - | <meta charset=" | + | |
| - | <meta http-equiv=" | + | } |
| - | <meta name=" | + | |
| - | < | + | |
| - | < | + | |
| - | | + | |
| - | border: 3px solid green; | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | float: right; | + | float: right; |
| - | } | + | } |
| - | | + | |
| - | overflow: auto; | + | overflow: auto; |
| - | } | + | } |
| - | + | ||
| - | .img2 { | + | |
| - | float: right; | + | |
| - | | + | |
| </ | </ | ||
| - | </ | + | |
| - | + | < | |
| - | < | + | <h2>Without |
| - | + | ||
| - | < | + | |
| <p> | <p> | ||
| - | In this example, the image is taller than the element containing it, and it is floated, so it overflows | + | This image is floated to the right. It is also taller than the element containing it, so it |
| + | | ||
| </p> | </p> | ||
| <div> | <div> | ||
| - | | + | |
| - | Lorem ipsum dolor sit amet, consectetur | + | Lorem ipsum dolor, sit amet consectetur |
| </ | </ | ||
| - | <p style=" | + | |
| - | | + | |
| + | We can fix this by adding | ||
| </p> | </p> | ||
| <div class=" | <div class=" | ||
| - | | + | |
| - | Lorem ipsum dolor sit amet, consectetur | + | Lorem ipsum dolor, sit amet consectetur |
| </ | </ | ||
| - | + | | |
| - | </body> | + | |
| - | + | ||
| - | </html> | + | |
| </ | </ | ||
| \\ | \\ | ||
| - | '' | + | '' |
| \\ | \\ | ||
| - | ====예제==== | + | ==== Example |
| - | < | + | < |
| - | <!DOCTYPE html> | + | <style> |
| - | <html lang=" | + | div { |
| + | border: 3px solid #4caf50; | ||
| + | padding: 5px; | ||
| + | } | ||
| - | < | + | |
| - | <meta charset=" | + | |
| - | <meta http-equiv=" | + | } |
| - | <meta name=" | + | |
| - | < | + | |
| - | < | + | |
| - | | + | |
| - | border: 3px solid green; | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | float: right; | + | float: right; |
| - | } | + | } |
| - | | + | |
| - | content: | + | content: |
| - | clear: both; | + | clear: both; |
| - | display: table; | + | display: table; |
| - | } | + | } |
| - | + | ||
| - | .img2 { | + | |
| - | float: right; | + | |
| - | | + | |
| </ | </ | ||
| - | </ | + | |
| - | + | <body> | |
| - | < | + | < |
| <p> | <p> | ||
| - | In this example, the image is taller than the element containing it, and it is floated, so it overflows | + | This image is floated to the right. It is also taller than the element containing it, so it |
| + | | ||
| </p> | </p> | ||
| <div> | <div> | ||
| - | < | + | |
| - | | + | Lorem ipsum dolor, sit amet consectetur |
| - | Lorem ipsum dolor sit amet, consectetur | + | |
| </ | </ | ||
| - | <p style=" | + | <h2>With New Modern Clearfix</ |
| - | Add a clearfix | + | < |
| - | | + | |
| <div class=" | <div class=" | ||
| - | | + | |
| - | Lorem ipsum dolor sit amet, consectetur | + | Lorem ipsum dolor sit amet, consectetur |
| </ | </ | ||
| - | + | | |
| - | </body> | + | |
| - | + | ||
| - | </html> | + | |
| </ | </ | ||
| {{tag> | {{tag> | ||