[CSS] float 연습

2022. 4. 8. 16:04·Stack/CSS

float clear 자세히 주말에 공부해보자 

 

float: 요소가 왼쪽, 오른쪽으로 떠 있도록 지정

left / right

 

clear: 요소의 왼쪽 오른쪽에 부동 요소를 허용하지 않도록 지정

left / right / both

 

1) display

2) float

3) flexbox

4) gridbox

 


 

1. float.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        #container {
            background: pink;
            width: 1000px;
            margin: 0 auto;
        }
        .item {
            background: tomato;
            width: 200px;
            height: 200px;
            border: 3px solid #333;
            float:left;
        }
        /* #clear{
            float: none;
            clear: left;
        } */
        #container2 {
            width: 1000px;
            height: 400px;
            background-color: blue;
        }
        #container p {
            clear:left;
        }
    </style>
</head>
<body>
    <!-- div>(div>{box$})*4 -->
    <div id="container">
        <div class="item">box1</div>
        <div class="item">box2</div>
        <div class="item">box3</div>
        <div class="item" id="clear">box4</div>
    </div>
    <div id="container2">
        <p>div입니다.</p>
        <p>div입니다.</p>
        <p>div입니다.</p>
        <p>div입니다.</p>
        <p>div입니다.</p>
        <p>div입니다.</p>
        <p>div입니다.</p>
        <p>div입니다.</p>
        <p>div입니다.</p>
        <p>div입니다.</p>
    </div>
</body>
</html>

 

2. float_header.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        #header {
            width: 1000px;
            background: pink;
            margin: 0 auto;
        }
        h1{
            float: left; /*뒤에 있던 ul이 위로 올라옴 */
        }
        ul {
            float: right;
        }
        .clearboth{
            clear: both; /* 보통 이거 만들어서 양쪽을 제거,, 이게 무슨 말이지 */
        }
        li{
            float:left;
        }
    </style>
</head>
<body>
    <div id="header">
        <h1>Green</h1>
        <ul>
            <li><a href="#">menu1</a></li>
            <li><a href="#">menu2</a></li>
            <li><a href="#">menu3</a></li>
            <li><a href="#">menu4</a></li>
        </ul>
        <p class="clearboth"></p>
    </div>
</body>
</html>

'Stack > CSS' 카테고리의 다른 글

[CSS] 의사 요소 (before / after)  (0) 2022.04.11
[CSS] float 복습 끄적끄적  (0) 2022.04.11
[CSS] background 연습  (0) 2022.04.08
[CSS] 페이지 똑같이 display ~  (0) 2022.04.08
[CSS] display 복습 끄적끄적  (0) 2022.04.08
'Stack/CSS' 카테고리의 다른 글
  • [CSS] 의사 요소 (before / after)
  • [CSS] float 복습 끄적끄적
  • [CSS] background 연습
  • [CSS] 페이지 똑같이 display ~
7ingout
7ingout
  • 7ingout
    Hello, 7ingout world!
    7ingout
  • 전체
    오늘
    어제
    • 분류 전체보기 (205)
      • Project (5)
      • Stack (173)
        • React (40)
        • JavaScript (50)
        • TypeScript (14)
        • HTML (11)
        • CSS (31)
        • Spring (9)
        • PHP (15)
        • SQL (3)
        • Python (0)
      • ETC (9)
      • Design (13)
        • Illustrator (6)
        • Photoshop (7)
      • Articloid (4)
        • 7ingout (4)
  • 공지사항

    • ☻
  • 인기 글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.0
7ingout
[CSS] float 연습
상단으로

티스토리툴바