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

标签 html css overlay

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

叠加动画演示:

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/

相关文章:

iphone - 使用 UIActivityIndi​​catorView 覆盖 View 的示例

JQuery 仅使用 html() 抓取特定文本

css - 图像的弹出文本。图片不在一条线上

java - 是否可以将 JPanel 覆盖在另一个 JPanel 之上?

jquery - 将自定义类添加到工具提示

html - HTML 中的不间断非空格

android - 如何从 Overlay onTap 方法将按下的位置返回到 MapActivity

javascript - 我想通过按回车键更改 HTML 文档的背景颜色

html - 如何在右上角正确放置 Bootstrap 指示器?

html - CSS - 元素的停止/开始动画,但与其他元素保持同步