网页效果 html + css
<!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>全民出游</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<!-- 云的图片 -->
<div class="cloud">
<img src="../study/images-全民出游/yun1.png" alt="">
<img src="../study/images-全民出游/yun2.png" alt="">
<img src="../study/images-全民出游/yun3.png" alt="">
</div>
<div class="san">
<img src="../study/images-全民出游/san.png" alt="">
</div>
<div class="font1">
<img src="../study/images-全民出游/font1.png" alt="">
</div>
<div class="nav">
<img src="../study/images-全民出游/1.png" alt="">
<img src="../study/images-全民出游/2.png" alt="">
<img src="../study/images-全民出游/3.png" alt="">
<img src="../study/images-全民出游/4.png" alt="">
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
position: relative;
height: 100%;
/* background 跟no-repeat要复合属性写,不能加image */
background: url(../study/images-全民出游/f1_1.jpg) no-repeat center 0;
/* 缩放背景图contain背景图等比例缩放,当宽度或者高度和盒子尺寸相等,图片就不再缩放 */
/* background-size: contain; */
/* 图片等比例缩放,图片完全覆盖到整个盒子,可能会 导致图片显示不全*/
background-size: cover;
}
/* 1.img引入图片,控制位置
2.定义动画,使用动画
*/
.cloud img {
position: absolute;
left: 50%;
top: 0;
}
.cloud img:nth-child(1) {
margin-top: 20px;
margin-left: -300px;
/* 匀速 无限循环 重复返回 */
animation: move 3s linear infinite alternate;
}
.cloud img:nth-child(2) {
margin-top: 100px;
margin-left: 400px;
/* 延迟0.2s */
animation: move 3s linear infinite alternate 0.2s;
}
.cloud img:nth-child(3) {
margin-top: 200px;
margin-left: -550px;
animation: move 3s linear infinite alternate 0.4s;
}
@keyframes move {
to {
transform: translateX(40px);
}
}
/* 热气球 */
.san img {
position: absolute;
left: 480px;
top: 150px;
animation: move1 2s linear infinite alternate;
}
@keyframes move1 {
to {
transform: translateY(30px);
}
}
.font1 img {
position: absolute;
left: 50%;
top: 50%;
animation:
font1 0.2s alternate,
font2 0.5s 0.2s steps(1) forwards
;
}
/* 中间的字有一个从0到放大的过程,然后再弹射到中间 */
@keyframes font1 {
from {
transform: scale(0);
}
to {
transform: scale(1.5);
}
}
@keyframes font2 {
to {
margin-left: -324px;
margin-top: -144px;
}
}
/* 最下面的四个按钮 */
.nav img {
position: absolute;
left: 50%;
top: 78%;
/* 因为图标有点大,所以这里限制图标的尺寸 */
width: 100px;
height: 125px;
}
.nav img:nth-child(1) {
margin-left: -400px;
animation: move2 1s infinite alternate;
}
.nav img:nth-child(2) {
margin-left: -200px;
animation: move2 1s infinite alternate 0.1s;
}
.nav img:nth-child(3) {
margin-left: 0;
animation: move2 1s infinite alternate 0.2s;
}
.nav img:nth-child(4) {
margin-left: 200px;
animation: move2 1s infinite alternate 0.3s;
}
@keyframes move2 {
to {
transform: translateY(30px);
}
}