效果图
代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body>* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.class1{
position: relative;
opacity: 0;
animation: pingyishang 2s ease;
animation-fill-mode: both;
border-radius: 10px;
}
.class2{
position: relative;
animation: dong 2s linear;
animation-iteration-count: infinite;
border-radius: 10px;
animation-direction: alternate;
}
#main {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-around;
width: 100%;
margin: 0 auto;
margin-top: 50px;
padding: 5px;
}
#div1 {
background-color: deepskyblue;
margin-right: 5px;
flex: 1;
transition: all 0.3s;
}
#div1:hover{
box-shadow: 1px 0 5px deepskyblue;
zoom: 1.01;
z-index: -1;
transform: scale(2.0,2.0)
}
#div2 {
background-color: orangered;
animation-delay: 0.8s;
margin-left: 5px;
margin-right: 5px;
flex: 1;
}
#div2:hover{
box-shadow: 1px 0 5px orangered;
}
#div3 {
background-color: yellowgreen;
animation-delay: 1.6s;
margin-left: 5px;
flex: 1;
}
#div3:hover{
box-shadow: 1px 0 5px yellowgreen;
}
@keyframes pingyishang {
from {
transform: translate(0, -100%);
opacity: 0.0;
}
to {
transform: translate(0, 0);
opacity: 0.8;
}
}
@keyframes dong{
from{
transform: translate(0,0);
opacity: 1.0;
}
10%{
transform: translate(0,1%);
opacity: 1.0;
}
20%{
transform: translate(0,2%);
opacity: 1.0;
}
40%{
transform: translate(0,3%);
opacity: 1.0;
}
60%{
transform: translate(0,0%);
opacity: 1.0;
}
80%{
transform: translate(0,-2%);
opacity: 1.0;
}
to{
transform: translate(0,-3%);
opacity: 1.0;
}
}
.title {
height: 100px;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-left: 10px;
margin-top: 10px;
margin-right: 10px;
background-color: white;
border-radius: 10px;
padding: 5px;
}
.img_div {
width: 100px;
height: 100px;
background-color: #000000;
border-radius: 5px;
transition: all 0.3s;
}
.img_div:hover{
transform: scale(1.05,1.05);
}
h3 {
margin-left: 20px;
margin-bottom: auto;
}
#content_hr {
height: 2px;
border:none;
margin-left: 10px;
margin-right: 10px;
background-color: rgb(212,225,238);
}
#detail {
position: absolute;
left: 10px;
right: 10px;
bottom: 10px;
top: 140px;
background-color: white;
border-radius: 10px;
padding-left: 10px;
padding-right: 10px;
padding-top: 0;
}
#block{
display: flex;
flex-direction: row;
margin-left: 15px;
align-items: center;
}
#resource-about{
width: auto;
margin-right: auto;
text-align: center;
}
#p-price{
margin-left: 5px;
color: black;
font-weight: bold;
}
#p-lable{
color: dimgrey;
font-size: 12px;
}
h3:hover,
#p-price:hover{
transform: scale(1.05,1.05);
}
#fenge-hr{
width: 1px;
background-color: lightgrey;
border: none;
}
#view-resource-btn{
transform: translate(0,60%);
height: 40px;
width: 100px;
border: none;
outline: none;
background-color: slategrey;
color: white;
border-radius: 5px;
font-size: 14px;
}
#view-resource-btn:hover{
box-shadow: 1px 1px 2px lightgrey;
font-size: 14.5px;
opacity: 0.7;
}
h4{
color: dimgray;
}
</style>
</head>
<body>
<div id="main" class="class1">
<div id="div1"class="class1">
<div class="title">
<div class="img_div"></div>
<div id="resource-about">
<h3>{{resourceName}}</h3>
<div id="block">
<p id="p-lable">积分:$</p>
<p id="p-price">{{resourcePrice}}</p>
</div>
</div>
<button id="view-resource-btn">查看资料</button>
</div>
<hr id="content_hr" />
<div id="detail">
<h4>资料详情</h4>
<p>{{resourceDetail}}</p>
</div>
</div>
<hr id="fenge-hr"/>
<div id="div2"class="class1">
<div class="title">
<div class="img_div"></div>
<div id="resource-about">
<h3>{{resourceName}}</h3>
<div id="block">
<p id="p-lable">积分:$</p>
<p id="p-price">{{resourcePrice}}</p>
</div>
</div>
<button id="view-resource-btn">查看资料</button>
</div>
<hr id="content_hr" />
<div id="detail">
<h4>资料详情</h4>
</div>
</div>
<hr id="fenge-hr" />
<div id="div3"class="class1">
<div class="title">
<div class="img_div"></div>
<div id="resource-about">
<h3>{{resourceName}}</h3>
<div id="block">
<p id="p-lable">积分:$</p>
<p id="p-price">{{resourcePrice}}</p>
</div>
</div>
<button id="view-resource-btn">查看资料</button>
</div>
<hr id="content_hr" />
<div id="detail">
<h4>资料详情</h4>
</div>
</div>
</div>
<script>
var height = window.innerHeight
var width = document.body.clientWidth
var title = document.getElementsByClassName("title")
var div_height = height - 100
var div_width = (width - 80) / 3
console.log(height + " " + width)
var main = document.getElementById("main")
main.style.height = div_height+"px"
main.style.width = width - 80+"px"
var div1 = document.getElementById("div1")
div1.style.height = div_height+"px"
div1.style.width = div_width+"px"
var div2 = document.getElementById("div2")
div2.style.height = div_height+"px"
div2.style.width = div_width+"px"
var div3 = document.getElementById("div3")
div3.style.height = div_height+"px"
div3.style.width = div_width+"px"
div2.addEventListener("webkitAnimationEnd",function(){
div1.setAttribute("class","class2")
div2.setAttribute("class","class2")
div3.setAttribute("class","class2")
})
</script>
</body>
</html>