微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

弹性盒子+CSS3帧动画

<!DOCTYPE html>
<html lang="en">

<head>
<Meta charset="UTF-8">
<Meta name="viewport" content="width=device-width,initial-scale=1.0">
<Meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
margin: 0px;
padding: 0px;
Box-sizing: border-Box;
}

.Box {
width: 400px;
height: 400px;
background: #999999;
border-radius: 10px;
display: flex;
/* 横向 */
/* flex-direction: row; */
/* 换行*/
/* flex-wrap: Nowrap; */
/* justify-content: center; 居中对齐 */
/* justify-content: space-between 两端对齐 */
/* justify-content: space-around; 两端间隔相等 */
/* align-items: flex-start; 顶端对齐 */
/* align-items: center; 居中对齐 */
/* align-items: flex-end; 底部对齐 */
/* align-items: baseline; 基线对齐 */
/* 多根轴线对齐方式 */
/* align-content: flex-start; 与交叉轴起点对齐 */
/* align-content: center; 与交叉轴中点对齐 */
/* align-content: flex-end; 与交叉轴终点对齐 */
/* align-content: space-between; 与交叉轴两端对齐,轴线之间的间隔平均分布 */
/* align-content: space-around; 每根轴线两侧的间隔相等,轴线之间的间隔比轴线与边框的间隔大一倍 */
/* align-content: stretch(认值); 轴线占满整个交叉轴 */
}

.Box div {
width: 100px;
height: 100px;
border: 1px solid black;
border-radius: 10px;
animation: one 2s;
background: linear-gradient(to right,red,yellow);
animation-iteration-count: infinite;
/* flex-grow: 1; 项目放大比例 */
}

.Box p {
animation: two 2s;
animation-iteration-count: infinite;
background: linear-gradient(to right,blue,red);
width: 200px;
height: 100px;
border: 1px solid black;
border-radius: 10px;
/* flex-grow: 1; 项目放大比例 */
/* flex-shrink: 1; */
}

.Box p:nth-of-type(2) {
flex-shrink: 0;
align-self: center;
}

.Box p:nth-of-type(3) {
align-self: flex-end;
}

/* .Box div:nth-child(2){
font-size: 60px;
order: -1; 项目排序
}
.Box div:nth-child(3){
font-size: 40px;
}
.Box div:nth-child(4){
font-size: 20px;
} */
@keyframes one {
0% {
background: linear-gradient(to right,yellow,red);
}

25% {
background: linear-gradient(to right,yellow);
}

50% {
background: linear-gradient(to right,red);
}

75% {
background: linear-gradient(to right,yellow);
}

100% {
background: linear-gradient(to right,red);
}
}

@keyframes two {
0% {
background: linear-gradient(to right,blue);
}

25% {
background: linear-gradient(to right,red);
}

50% {
background: linear-gradient(to right,blue);
}

75% {
background: linear-gradient(to right,red);
}

100% {
background: linear-gradient(to right,blue);
}
}
</style>
</head>

<body>
<div class="Box">
<div>1</div>
<p>1</p>
<p>2</p>
<p>3</p>
</div>
</body>

</html>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。