CSS 16 background-position 속성으로 배경 이미지 위치 설정하기

프론트엔드/CSS|2021. 3. 21. 13:49

배경 이미지

초보개발자의 성장블로그

background-position : left center 속성 적용됨

background-position : center 속성 적용됨

background-position : right center속성 적용됨

<!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>배경 이미지</title>
    <style>
         div#a{
             width:70%;
             height: 200px;
            background-image:url("https://images.pexels.com/photos/1471294/pexels-photo-1471294.jpeg?cs=srgb&dl=pexels-adi-kavazovic-1471294.jpg&fm=jpg");
            background-size:10%;
            border: 1px solid black;
            background-repeat: no-repeat;
            background-position: left center;    

        }
        div#b{
            background-image:url("http://freeppt.co.kr/wp-content/uploads/2018/09/man.png");
            width:70%;
            height: 200px;
            background-size:10%;
            background-repeat: no-repeat;
            background-position:center;    
            border: 1px solid black;            
        }
        div#c{
            background-image:url("http://freeppt.co.kr/wp-content/uploads/2018/09/man.png");
            width:70%;
            height: 200px;
            background-size:10%;
            background-repeat: no-repeat;
            border: 1px solid black;        
            background-position:right center;    
        }      
    </style>
</head>
<body>
    <h1>초보개발자의 성장블로그</h1>
    <div id="a">
        <h2 style="color: black;">background-position : left center 속성 적용됨</h2>
    </div>
    <div id="b">
        <h2 style="color: black;">background-position : center 속성 적용됨</h2>
    </div>
    <div id="c">
        <h2 style="color: black;">background-position : right center속성 적용됨</h2>
    </div>
</body>
</html>

댓글()
구독