gpt4 book ai didi

html - 带图标的CSS图片叠加效果

转载 作者:行者123 更新时间:2023-11-28 15:24:14 32 4
gpt4 key购买 nike

我目前正在尝试制作一个带有图标滑入的图像叠加动画,但不知道如何在代码中执行。我找不到应用动画的方法。我有我想要的动画类型的插入链接。

叠加动画演示:

overlay animation link

如果有人能做到,请帮助我。以下是我到目前为止尝试过的代码:

@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>

最佳答案

我相信这就是你想要的。

在每个 anchor 标签之后,您可以插入:

<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>


CodePen Demo

关于html - 带图标的CSS图片叠加效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45575962/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com