- index.html
- style.css
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The background-attachment Property</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
</body>
</html>
CSS
body {
background-color: black;
background-image: url("moon.jpg");
background-position: 50% 0;
background-repeat: no-repeat;
}
.block {
width: 192px;
height: 256px;
margin: 20px auto;
background-color: #34495e;
background-repeat: no-repeat;
background-position: 50% 50%;
border-radius: 5px;
}
.block:nth-child(1) {
background-image: url("cat_clean.png");
}
.block:nth-child(2) {
background-image: url("cat_fight.png");
}
.block:nth-child(3) {
background-image: url("cat_hiss.png");
}
.block:nth-child(4) {
background-image: url("cat_poo.png");
}
You’ve gone to a different page
Goalscompleted
0
- Assign “fixed” background image mode to
body
.
Check to see how the background image behaves by scrolling the mini-browser window.
Comments