clear: both : float 속성을 해제한다



html)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" 
          content="width=device-width, height=device-height, 
                     minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0">
    <title>Insert title here</title>
    <style>
    .container {
        background: #FFD8D8;
    }
    .container img {
        float: left;
    }
    .container:after {
        content: "";
        display: block;
        
        /* clear: both : float을 감싸고 있는 div태그가 끝나기전 float 속성을 해제한다 */
        clear: both;
    }
    .footer {
        background: #D9E5FF;
    }
    </style>
</head>
 
<body>
    <div class="container">
        <img src="http://placehold.it/120x200" />
        
        <img src="http://placehold.it/120x200" />
    </div>
    
    <div class="footer">
        <address>안녕히 가세요.</address>
    </div>
</body>
</html>
cs



결과

float 속성이 해제되어 화면이 깨지지 않는다


+ Recent posts