본문 바로가기
CSS

[CSS] class

by 기록하는_사람 2022. 9. 13.

class

📌 class

: 여러 요소가 같이 사용할 수 있음

  한 요소는 여러 클래스를 가질 수 있음

  .(클래스명) { }

 

예시

<!DOCTYPE html>
<html>
    <head>
        <title>HTML 기본 형식</title>
        <link href="styles.css" rel="stylesheet"/>
        <style>
            html {
                background-color: blanchedalmond;
            }
            body {
                margin: 20px;
            }
            .btn {
                padding: 5px;
                border-radius: 10px;
            }
            .olive {
                background-color: olive;
                color: beige;
            }
            .tomato {
                background-color: tomato;
                color: beige;
            }
        </style>
    </head>
    <body>
        <span class="btn olive">class</span>
        <span class="btn tomato">class</span>
        <span class="btn olive">class</span>
        <span class="btn tomato">class</span>
        <span class="btn olive">class</span>
        <span class="btn tomato">class</span>
    </body>
</html>

'CSS' 카테고리의 다른 글

[CSS] Flexbox  (0) 2022.09.14
[CSS] block | inline | inline-block  (0) 2022.09.14
[CSS] box - margin, border, padding  (2) 2022.09.13
[CSS] box  (2) 2022.09.13
[CSS] CSS 기본 설명  (0) 2022.09.13

댓글