background-color
배경색을 지정할 때 사용
<style>
body{
background-color: skyblue;
}
#div-bg{
background-color: white;
border:30px solid blue;
padding : 20px;
width : 50%;
box-sizing: content-box;
box-sizing : border-box;
}
</style>
<body>
<div id="div-bg">
날카로우나 일월과 창공에 같은 것이다. 할지니, 수 일월과 이상을 봄바람이다.
얼음과 놀이 귀는 인도하겠다는 인생을 같이,
</div>
</body>
background-clip
배경을 적용시키고자 하는 범위를 지정할 때 사용
[표현법]
선택자 {
background-clip : border-box / padding-box / content-box;
}
<style>
.div-test{
margin : 30px;
border : 10px dashed;
padding : 20px;
background-color: yellow;
}
#div1{
background-clip: border-box;
}
#div2{
background-clip: padding-box;
}
#div3{
background-clip: content-box;
}
</style>
<body>
<div class="div-test" id="div1">
동력은 생의 그들을 얼마나 아름다우냐?
</div>
<div class="div-test" id="div2">
동력은 생의 그들을 얼마나 아름다우냐?
</div>
<div class="div-test" id="div3">
동력은 생의 그들을 얼마나 아름다우냐?
</div>
</body>
배경 이미지 테스트
[표현법]
선택자{
background-image : url("이미지경로");
background-repeat : repeat / repeat-x / repeat-y / no-repeat
background-size : auto / contain / cover / 가로길이(px);
background-position : 좌 / 우 / 가운데 중 하나 , 위 / 아래 / 가운데 중 하나 선택
또는 x좌표(px,%) y좌표(%);
background-attachment : scroll / fixed;
}
<style>
#bg-img{
border : 1px solid black;
width : 70%;
height : 800px;
background-image: url("resources/image/bono.jpg");
background-repeat: repeat-x;
background-repeat: repeat-y;
background-repeat: no-repeat;
background-size:auto;
background-size:contain;
background-size: cover;
background-size: 100%;
background-position: 50% 50%;
background-attachment : scroll;
background-attachment : fixed;
}
</style>
<body>
<div id="bg-img"></div>
</body>