2022. 12. 23. 12:06ㆍ코딩배움일지/Web 구현
background-color 속성
웹 문서의 요소에 배경색 지정
16진수나 rgb 값, rgba 값 또는 색상 이름 사용
배경색은 상속되지 않는다
background-clip 속성
배경을 어디까지 적용할지 지정 ( padding 까지 먹힌다.)
<!DOCTYPE html>
<html lang="ko">
<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>Document</title>
<style>
.box{
border: 50px solid red;
padding: 50px 50px;
width: 100px;
height: 100px;
background-color: blue;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
클립까지
<!DOCTYPE html>
<html lang="ko">
<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>Document</title>
<style>
.box{
border: 5px solid red;
padding: 50px 50px;
width: 100px;
height: 100px;
background-color: blue;
background-clip: content-box;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
히든 잡고 패딩
<style>
.box{
border: 5px hidden red;
padding: 50px 50px;
width: 100px;
height: 100px;
background-color: blue;
background-clip: padding-box;
}
</style>
솔리드 보더박스
<style>
.box{
border: 5px solid red;
padding: 50px 50px;
width: 100px;
height: 100px;
background-color: blue;
background-clip: border-box;
}
</style>
background-image 속성
배경 이미지 파일 경로 지정
background-repeat 속성
배경 이미지 반복 여부 및 반복 방향 지정
repeat 은 기본값
background-position 속성
배경 이미지를 반복하지 않을 경우, 배경 이미지를 표시할 위치 지정
① 백분율 : 배경 이미지의 가로 위치와 세로 위치를 %로 나타냄.
예) background-postion: 0% 0% , background-position : 30% 60%
② 길이 : 배경 이미지의 위치를 직접 길이로 지정
예) background-position:30px 20px;
③ 키워드 - top, left, center, right, top, middle, bottom
가로 배치는 left와 center, top 중에서 선택
세로 배치는 top과 bottom, center 중에서 선택
예) background-position:center bottom
background-origin 속성
배경 이미지를 배치하기 위한 기준 설정
background-attachment 속성
배경 이미지를 고정하는 속성
background 속성
배경 관련 속성을 줄여서 표기
각 속성 값이 다르므로 표기 순서는 상관없음
background-size 속성
배경 이미지 크기 조절
<style>
.box{
border: 5px solid black;
padding: 50px 50px;
width: 900px;
height: 900px;
background-image: url(/images/github2.png);
background-repeat: no-repeat;
background-position: center; /*center 안주면 잘린다.*/
background-size: cover;
}
</style>
backgroud html
<!DOCTYPE html>
<html lang="ko">
<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>Document</title>
<style>
.box{
border: 5px solid black;
padding: 50px 50px;
width: 900px;
height: 900px;
background-image: url(/images/github2.png);
background-repeat: no-repeat;
background-position: center; /*center 안주면 잘린다.*/
background-size: 100%; /*auto 는 이미지 본래사이즈를 지킨다.*/
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
'코딩배움일지 > Web 구현' 카테고리의 다른 글
Web 클론 페이지 (선생님 과제 Kakao Oven) (0) | 2022.12.25 |
---|---|
Web 4일차 4(반응형 웹) (0) | 2022.12.23 |
Web 4일차 2(position, border-radius) (0) | 2022.12.23 |
Web 4일차 1(display) (0) | 2022.12.23 |
Web 3일차 2(css 블록) (1) | 2022.12.22 |