background-attachment background-position background-size ackground-repeat
/* background:url(`image.jpeg`)
background-repeat
background-size
background-position
background-attachment
shorthand syntax*/
INDEX.HTML:
<!DOCTYPE html>
<html lang="en">
<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>CSS Tutorial</title>
<link rel="stylesheet" href="styles.css">
</head>
<body >
<div class="big-img">
<h1>I'M BIG IMAGE</h1>
</div>
<div class="small-img">
<h1>I'M SMALL IMAGE</h1>
</div>
<div class="folder-img">
<h1>I'M FOLDER IMAGE</h1>
</div>
</body>
</html>
CSS:
/*
background:url(`image.jpeg`)
background-repeat
background-size
background-position
background-attachment
shorthand syntax
*/
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
div{
color: red;
height: 400px;
font-size: 60px;
display: flex;
text-align: center;
align-items: center;
justify-content: center;
}
.big-img {
background:url('iceland.jpg');
background-repeat: no-repeat;
background-size:cover;
background-position: center;
background-attachment: fixed;
}
.small-img {
border: 2px solid red;
background: url('./detox.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
}
.folder-img {
background: url('./detox.jpg');
}
评论
发表评论