- index.html
- style.css
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>Background Size, Step 2</title>
<meta charset="utf-8">
<link rel="stylesheet" href="setting.css">
<link rel="stylesheet" href="style.css">
</head>
<body class="set">
<div class="portrait-vertical portrait-1"></div>
<div class="portrait-vertical portrait-2"></div>
<br>
<div class="portrait-horizontal portrait-3"></div>
<div class="portrait-horizontal portrait-4"></div>
</body>
</html>
CSS
[class^="portrait"] {
background: url("img/muffin.jpg") no-repeat #ffffff;
background-size: 100px auto;
}
.portrait-vertical {
width: 150px;
height: 200px;
}
.portrait-horizontal {
width: 200px;
height: 150px;
}
You’ve gone to a different page
Goalscompleted
0
- Assign the background size
contain
to the.portrait-1
block, - assign
cover
to.portrait-2
, - assign
contain
to.portrait-3
- and assign
cover
again to.portrait-4
,
Comments