본문 바로가기
HTML

32일차//[css] body { background } 속성

by aesup 2021. 2. 25.
728x90

속성값

 

background 속성값은 아래에서 파란색으로 표시된 부분을 참조해서 적습니다.

 

 

background-color,  배경 색깔 지정

 : 16진수(#ff0000), 색 이름(red), rgb 값 rgb(255,0,0) 중에서 선택

 

예) body{background: green;}

 

 

background-image 배경 이미지 주소 지정

 :  url('rabbit.png');

 

예) body{background: url('brabbit.png');}

 

background-repeat 배경 이미지 패턴 지정

: repeat 기본값, repeat-x  가로 반복, repeat-y  세로 반복 no-repeat  반복되지 않음

 

예) body{background: repeat-x;}

 

 

background-attachment 배경 이미지 고정 방식

: scroll 기본값 fixed,  local 중 선택

 

예) body{background: fixed;}

 

background-position 배경 위치 지정

: left right center (가로) top center bottom(세로),  %  , cm,px, em 등에서 선택

 

예) body{background: left center;}

 

background-size 배경 이미지 크기 지정

: auto, px, %, cover, contain 중에서 선택

 

예) body{background:100px 100px;}

 

상속 여부 :  no

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<style type="text/css">

body{
	/*
	background-color: red;
	background-image: url("back.jpg");
	background-repeat: no-repeat;
	background-position: right top;
	*/
	
	background: #00ff00
				url("back.jpg") 
				no-repeat 
				right top;
	

}


</style>

</head>
<body>




</body>
</html>

728x90