본문 바로가기
☁️ 구름 X kakao DeepDive/☁️ HTML CSS JS

[CSS] 3일차 CSS (Background-Clip)

by 뽀짜꼬 2024. 11. 17.

Background-Clip

: 요소 내에서 배경(색상 또는 이미지)가 확장되어야 하는 거리를 정의함.

background-clip: border-box; 테두리까지 확장됨

background-clip: padding-box; 패딩까지만 확장됨

background-clip: content-box; 컨텐츠까지만

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Document</title>
    <style>
        #example1 {
            border: 10px dotted black;
            padding: 15px;
            background-color: lightcoral;
            /* 백그라운드클립은 여기 */
            background-clip: border-box;
        }

        #example2 {
            border: 10px dotted black;
            padding: 15px;
            background-color: lightcoral;
            background-clip: padding-box;
        }

        #example3 {
            border: 10px dotted black;
            padding: 15px;
            background-color: lightcoral;
            background-clip: content-box;
        }
    </style>
</head>

<body>
    <p>background-clip: border-box (this is default):</p>
    <div id="example1">
        <p>The background extends behind the border. 테두리까지 확장</p>
    </div>

    <p>background-clip: padding-box:</p>
    <div id="example2">
        <p>The background extends to the inside edge of the border. 엣지까지만 확장</p>
    </div>

    <p>background-clip: content-box:</p>
    <div id="example3">
        <p>The background extends to the edge of the content box. 콘텐츠까지만 확장</p>
    </div>

</body>

</html>