반응형 웹사이트 - inline, block, inline-block, position 속성 복습

민겸·2023년 4월 8일
0

Making Portfolio

목록 보기
12/13

인라인요소

  • 크기값을 지정못함
  • 한줄에 여러개 배치
  • 상하마진 못가짐
  • 기본 너비값은 컨텐츠의 너비값
  • span, a, small, em, b, br, audio, video, s, u, mark, q, strong, sup, sub, i, big, del, label

블록요소

  • 크기값을 지정할 수 있음
  • 한줄에 한개만 배치
  • 상하좌우마진 모두 가짐
  • 기본 너비값은 100%
  • div, ul, ol, li, h, hr, form, dl, dt, dd, p, table, header, article, footer, section, nav, details, summury, center

인라인 블록요소

  • 크기값을 지정할 수 있음
  • 한줄에 여러개 배치
  • 상하좌우마진 모두 가짐
  • 기본 너비값은 컨텐츠의 너비값
  • img, input, button, fontawesome icon

Position

  • 어떤 요소이건 position: absolute 또는 fixed가 적용되면 인라인 블록으로 변함.

  • :before :after는 기본적으로 인라인요소

실습

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>display 속성의 이해도</title>

    <link rel="stylesheet" href="./assets/css/style.css">
</head>
<body>
<!--     인라인 요소, 블럭 요소, 인라인 블럭 요소의 복습
    <span>Inline Elements...etcetc...</span>
    <span>Inline Elements...etcetc...</span>
    <span>Inline Elements...etcetc...</span>

    <div>Block Elements1</div>
    <div>Block Elements2</div>

    <img src="./assets/image/picture-01.jpg">
    <img src="./assets/image/picture-01.jpg">

    <h1>Block Elements</h1> -->

    <!-- position의 복습 -->
    <!-- <div>Block Elements</div> -->


    <!-- before과 after 는 기본적으로 인라인 요소 -->
    <h1>Headline Text</h1>
    

    <script src="./assets/js/script.js"></script>
</body>
</html>

CSS

/* span{
    border: 1px solid black;
    width: 400px;
    height: 200ox;
    margin: 20px;
}

div{
    border: 1px solid red;
    margin: 20px;
    width: 300px;
    height: 50px;
}

img{
    margin: 20px;
    width: 300px;
    height: 300px;
}
h1{
    border: 1px solid blue;
    display: inline-block;
} */


/* 
어떤 요소이건 position: absolute 또는 fixed가 적용되면 인라인블록으로 변함.
*/
div{
    border: 1px solid black;
    position: absolute;
    /* display: block; */
    /* display: inline-block; */
    width: 400px;
    height: 100px;
    margin: 50px;
}


/* before after는 기본적으로 인라인요소  */
h1{
    border: 1px solid black;
}
h1:before{
    content: 'new';
    color: red;
    border: 1px solid green;
    width: 100px;
    height: 100px;
    margin: 20px;
    position: absolute;
}
h1:after{
    content: 'hot';
    color: blue;
}

0개의 댓글