我目前正在尝试制作带有图标幻灯片的图像叠加动画,但却没有让它如何在代码中执行。我找不到应用动画的方法。我有插入我想要的动画类型的链接。
叠加动画演示:
如果有人能做到,请帮助我。以下是我迄今为止尝试过的代码:
@import url('https://fonts.googleapis.com/css?family=Pacifico');
body {
font-family: Montserrat, sans-serif;
margin:0;
padding:0;
}
.xop-section {
background-color: #EFEEEE;
margin: 0;
}
.xop-grid {
margin:0;
padding:10% 0 10% 0;
list-style: none;
text-align: center;
width: 100%;
display:flex;
flex-wrap:wrap;
justify-content: center;
}
.xop-grid:after {
clear: both;
}
.xop-grid:after,
.xop-box:before {
content: '';
/* display: table;*/
}
.xop-grid li {
width: 700px;
height: 450px;
margin: 30px 27px;
padding: 0;
}
.xop-box {
width: 100%;
height: 100%;
position: relative;
cursor: pointer;
-webkit-transition: 0.3s ease-in-out, -webkit-transform 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out, -moz-transform 0.3s ease-in-out;
transition: all 0.3s ease-in-out, transform 0.3s ease-in-out, ;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
}
.xop-box:hover {
box-shadow: 0 8px 50px 0 rgba(0,0,0,0.3);
bottom: 0;
height: 100%;
}
.xop-img-1 {
background: url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/QQXLXMX04M.jpg);
}
.xop-img-2 {
background:
url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/X8UKHZIPSB.jpg);
}
.xop-img-3 {
background:
url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/MQYJBYKTVK.jpg);
}
.xop-img-4 {
background:
url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/T6OD5MKEY1.jpg);
}
.xop-img-5 {
background:
url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/CG0HVMG2OF.jpg);
}
.xop-img-6 {
background:
url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/NIRVEY04MU.jpg);
}
.xop-img-1 , .xop-img-2 , .xop-img-3 , .xop-img-4 , .xop-img-5 ,
.xop-img-6 {
background-size: cover;
}
@media only screen and (max-width: 1111px){
.xop-grid li {
width: 400px;
height: 300px;
margin: 30px 20px;
}
}

<div class="xop-section">
<ul class="xop-grid">
<li>
<div class="xop-box xop-img-1">
<a href="#">
</a>
</div>
</li>
<li>
<div class="xop-box xop-img-2">
<a href="#">
</a>
</div>
</li>
<li>
<div class="xop-box xop-img-3">
<a href="#">
</a>
</div>
</li>
<li>
<div class="xop-box xop-img-4">
<a href="#">
</a>
</div>
</li>
<li>
<div class="xop-box xop-img-5">
<a href="#">
</a>
</div>
</li>
<li>
<div class="xop-box xop-img-6">
<a href="#">
</a>
</div>
</li>
</ul>
</div>
&#13;
答案 0 :(得分:1)
我相信这就是你想要的。
在每个锚标记之后,您可以插入:
<div class="overlay">
<span class='icon'>+</span>
</div>
下面的css设置了叠加层和+
符号的样式,就像你在图片中一样。
查看此代码段。我还在下面发布了一个演示。
@import url('https://fonts.googleapis.com/css?family=Pacifico');
body {
font-family: Montserrat, sans-serif;
margin: 0;
padding: 0;
}
.xop-section {
background-color: #EFEEEE;
margin: 0;
}
.xop-grid {
margin: 0;
padding: 10% 0 10% 0;
list-style: none;
text-align: center;
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.xop-grid:after {
clear: both;
}
.xop-grid:after,
.xop-box:before {
content: '';
}
.xop-grid li {
width: 700px;
height: 450px;
margin: 30px 27px;
padding: 0;
}
.xop-box {
width: 100%;
height: 100%;
position: relative;
cursor: pointer;
-webkit-transition: 0.3s ease-in-out, -webkit-transform 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out, -moz-transform 0.3s ease-in-out;
transition: all 0.3s ease-in-out, transform 0.3s ease-in-out;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.xop-box:hover {
box-shadow: 0 8px 50px 0 rgba(0, 0, 0, 0.3);
bottom: 0;
height: 100%;
}
.xop-box .overlay {
background-color: rgba(0, 0, 0, 0.7);
overflow: hidden;
opacity: 0;
height: 100%;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
.xop-box:hover .overlay {
opacity: 1;
}
.xop-box .icon {
color: #fff;
border: solid 5px #fff;
border-radius: 40px;
left: 0;
right: 0;
margin: 0 auto;
margin-top: -2.5rem;
top: 0;
position: absolute;
width: 60px;
height: 60px;
font-size: 4em;
line-height: 0.8;
transition: .5s ease;
}
.xop-box:hover .icon {
top: 50%;
}
.xop-img-1 {
background: url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/QQXLXMX04M.jpg);
}
.xop-img-2 {
background: url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/X8UKHZIPSB.jpg);
}
.xop-img-3 {
background: url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/MQYJBYKTVK.jpg);
}
.xop-img-4 {
background: url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/T6OD5MKEY1.jpg);
}
.xop-img-5 {
background: url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/CG0HVMG2OF.jpg);
}
.xop-img-6 {
background: url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/NIRVEY04MU.jpg);
}
.xop-img-1,
.xop-img-2,
.xop-img-3,
.xop-img-4,
.xop-img-5,
.xop-img-6 {
background-size: cover;
}
@media only screen and (max-width: 1111px) {
.xop-grid li {
width: 400px;
height: 300px;
margin: 30px 20px;
}
}
<div class="xop-section">
<ul class="xop-grid">
<li>
<div class="xop-box xop-img-1">
<a href="#">
</a>
<div class="overlay">
<span class='icon'>+</span>
</div>
</div>
</li>
<li>
<div class="xop-box xop-img-2">
<a href="#">
</a>
<div class="overlay">
<span class='icon'>+</span>
</div>
</div>
</li>
<li>
<div class="xop-box xop-img-3">
<a href="#">
</a>
<div class="overlay">
<span class='icon'>+</span>
</div>
</div>
</li>
<li>
<div class="xop-box xop-img-4">
<a href="#">
</a>
<div class="overlay">
<span class='icon'>+</span>
</div>
</div>
</li>
<li>
<div class="xop-box xop-img-5">
<a href="#">
</a>
<div class="overlay">
<span class='icon'>+</span>
</div>
</div>
</li>
<li>
<div class="xop-box xop-img-6">
<a href="#">
</a>
<div class="overlay">
<span class='icon'>+</span>
</div>
</div>
</li>
</ul>
</div>
答案 1 :(得分:0)
你可以将透明div的位置绝对放在不透明度为0的位置,并在其上添加用于盒子阴影的相同动画。然后,当您将鼠标悬停在透明div上时,它将变为.5不透明度。与您可以放在里面并链接图标的链接相同。
@import url('https://fonts.googleapis.com/css?family=Pacifico');
body {
font-family: Montserrat, sans-serif;
margin:0;
padding:0;
}
.xop-section {
background-color: #EFEEEE;
margin: 0;
}
.xop-grid {
margin:0;
padding:10% 0 10% 0;
list-style: none;
text-align: center;
width: 100%;
display:flex;
flex-wrap:wrap;
justify-content: center;
}
.xop-grid:after {
clear: both;
}
.xop-grid:after,
.xop-box:before {
content: '';
/* display: table;*/
}
.xop-grid li {
width: 700px;
height: 450px;
margin: 30px 27px;
padding: 0;
}
.xop-box {
width: 100%;
height: 100%;
position: relative;
cursor: pointer;
-webkit-transition: 0.3s ease-in-out, -webkit-transform 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out, -moz-transform 0.3s ease-in-out;
transition: all 0.3s ease-in-out, transform 0.3s ease-in-out, ;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
}
.transparent{
-webkit-transition: 0.3s ease-in-out, -webkit-transform 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out, -moz-transform 0.3s ease-in-out;
transition: all 0.3s ease-in-out, transform 0.3s ease-in-out, ;
position:absolute;
z-index:10;
left:0;
right:0;
top:0;
bottom:0;
background-color:rgba(0,0,0,0);
display:block;
}
.transparent a{
color:rgba(255,255,255,0);
}
.transparent:hover a{
color:rgba(255,255,255,1);
position: relative;
top: 50%;
transform: translateY(-50%);
}
.transparent:hover{
background-color:rgba(0,0,0,.5);
}
.xop-box:hover {
box-shadow: 0 8px 50px 0 rgba(0,0,0,0.3);
bottom: 0;
height: 100%;
}
.xop-img-1 {
background: url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/QQXLXMX04M.jpg);
}
.xop-img-2 {
background:
url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/X8UKHZIPSB.jpg);
}
.xop-img-3 {
background:
url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/MQYJBYKTVK.jpg);
}
.xop-img-4 {
background:
url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/T6OD5MKEY1.jpg);
}
.xop-img-5 {
background:
url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/CG0HVMG2OF.jpg);
}
.xop-img-6 {
background:
url(https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/NIRVEY04MU.jpg);
}
.xop-img-1 , .xop-img-2 , .xop-img-3 , .xop-img-4 , .xop-img-5 ,
.xop-img-6 {
background-size: cover;
}
@media only screen and (max-width: 1111px){
.xop-grid li {
width: 400px;
height: 300px;
margin: 30px 20px;
}
}
&#13;
<div class="xop-section">
<ul class="xop-grid">
<li>
<div class="xop-box xop-img-1">
<div class="transparent"><a href="#">Icon</a>
</div>
</div>
</li>
<li>
<div class="xop-box xop-img-2">
<div class="transparent"><a href="#">Icon</a> </div>
</div>
</li>
<li>
<div class="xop-box xop-img-3">
<div class="transparent"><a href="#">Icon</a></div>
</div>
</li>
<li>
<div class="xop-box xop-img-4">
<div class="transparent"><a href="#">Icon</a>
</div>
</div>
</li>
<li>
<div class="xop-box xop-img-5">
<div class="transparent"><a href="#">Icon</a>
</div>
</div>
</li>
<li>
<div class="xop-box xop-img-6">
<div class="transparent"><a href="#">Icon</a>
</div>
</div>
</li>
</ul>
</div>
&#13;