728x90

크기  height/width

 

Box1

 

<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>박스크기</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <style>
        div{
            border: 5px solid black;
        }
        .box1{
            width: 400px;
            height: 200px;
        }
    </style>
</head>
<body>
    <div class="box1">박스1</div>
</body>
</html>
 
cs

 

height : 높이

width : 너비

max-width : 최대 너비

min-width : 최소 너비

max-height : 최대 높이

min-heigt : 최소 높이

 

 

 

 

박스 모델  box-modeling

 

box1

margin : 테두리 바깥쪽 여백

  - margin: 30px;                    상하좌우 모두 동일값
  - margin: 30px 60px;              상하  &  좌우 동일값
  - margin: 10px 20px 30px 40px;    상 우 하 좌 시계방향 지정


border : 테두리
padding : 테두리 안쪽 여백
content : 실제 내용이 표시되는 영역

 

 

 

 

box2
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>박스크기</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <style>
        div{
            border: 5px solid black;
        }
        .box1{
            width: 400px;
            height: 200px;
            margin: 30px;
            padding: 30px;
        }
    </style>
</head>
<body>
    <div class="box1">박스1</div>
</body>
</html>
 
cs

 

 

 

 

box3
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>박스크기</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <style>
        div{
            border: 5px solid black;
        }
        .box3{
            width: 300px;
            height: 300px;
            margin: 10px 20px 30px 40px;
            padding: 10px 20px 30px 40px;
        }
    </style>
</head>
<body>
    <div class="box3">박스3</div>
</body>
</html>
 
cs

 

 
 
 
 

박스 사이즈  box-sizing

"border-box" : border 까지의 크기가 300px ((20px*2)+(50px*2)+160px)

 

content-box : content 까지의 크기가 300px

 

기본값
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>box-sizing</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <style>
        div{
            width: 300px;
            height: 300px;
            padding: 50px;
            border: 20px solid black;
            margin-top: 50px;
        }
        .box1{
            border-color: red;
            box-sizing: border-box;
        }
        .box2{
            border-color: blue;
            box-sizing: content-box;
        }
    </style>
</head>
<body>
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>
</body>
</html>
 
cs

 

 

728x90

BELATED ARTICLES

more