Background 관련 속성은 해당 요소의 배경으로 이미지나 색상을 정의한다.
요소에 배경 이미지를 지정한다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body{
background-image: url("./html.png");
}
</style>
<title>Document</title>
</head>
<body>
</body>
</html>
배경 이미지의 반족을 지정한다. 수직 수평의 반복을 지정할 수 있다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body{
background-image: url("./html.png");
background-repeat: repeat-x;
}
</style>
<title>Document</title>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body{
background-image: url("./html.png");
background-repeat: repeat-y;
}
</style>
<title>Document</title>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body{
background-image: url("./html.png");
background-repeat: no-repeat;
}
</style>
<title>Document</title>
</head>
<body>
</body>
</html>
배경 이미지의 사이즈를 지정한다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body{
background-image: url("./html.png");
background-repeat: no-repeat;
background-size: 700px 500px;
}
</style>
<title>Document</title>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body{
background-image: url("./html.png");
background-repeat: no-repeat;
background-size: cover;
}
</style>
<title>Document</title>
</head>
<body>
</body>
</html>