重新创建Adobe Portfolio双悬停效果图像&文字块

时间:2017-12-23 23:16:40

标签: javascript html css hover

我一直试图重新创建https://andreas-demo.myportfolio.com/

上的悬停双重效果

然而我似乎无法使两者正确对齐然后我无法获得悬停在整个部分上的影响,但是这会改变:1 - 使图像变暗,2 - 反转颜色。

我希望能够在将鼠标悬停在整个区块上时发生两种影响,就像在上面的网站上一样。

这是我的代码;

img {
  display: block;
  width: 60%;
  height: 450px;
  background-color: #f2f2f2;
  !important;
  -webkit-filter: brightness(100%);
}

a img:hover {
  -webkit-filter: brightness(60%);
  -webkit-transition: all 1s ease;
  -moz-transition: all 1s ease;
  -o-transition: all 1s ease;
  -ms-transition: all 1s ease;
  transition: all 1s ease;
}

.media {
  background-color: #f2f2f2;
  !important;
  text-align: center;
}

p {
  display: inline-block;
  vertical-align: middle;
}
<div class="container">
  <a href="">
    <div class="media">
      <img src="img/pexels-photo-733438.jpeg" class="img-fluid" alt="Responsive image">
      <p>PROJECT 1</p>
      <p>2017</p>
    </div>
  </a>
</div>

2 个答案:

答案 0 :(得分:0)

在容器上:悬停,将容器'背景颜色设置为黑色(默认为白色),并将图像不透明度设置为0.5。

答案 1 :(得分:0)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="bcmMain" style="display: block;"> <h1 id="event-title"><span class="view-table-value" data-field-name="mopId">927</span> - <span class="view-table-value" data-field-name="subject">Sample Subject</span></h1> <div class="toolbar"> <div class="status-toolbar-group toolbar-group"> <a class="button" id="level-button">Level <span class="view-table-value" data-field-name="level">3</span></a> </div> <div class="toolbar-group"> <a class="button" id="status-button">Status: <span class="view-table-value" data-field-name="status">complete</span>|</a> <a class="button" id="pending-button">Mark Pending</a> </div> <div class="edit-toolbar-group toolbar-group"> <a class="button" id="submit-changes-button">Submit|</a> <a class="button" id="cancel-changes-button">Cancel</a> </div> <div class="toolbar-group"> <a class="button" id="edit-button">Edit|</a> <a class="button" id="clone-button">Clone</a> </div> </div> <div id="edit-details"> content - first<br>content - second<br>content - third<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content - forelast<br>content - last<br> </div> </div>伪类移动到3个父(包装)元素之一 -  :hover.container.container > a元素。这样可以将覆盖添加到.media上的两个元素。

像这样:

&#13;
&#13;
:hover
&#13;
.container {
  font-family: Arial;
}

.container:hover {
  -webkit-transition: all 1s ease;
  -moz-transition: all 1s ease;
  -o-transition: all 1s ease;
  -ms-transition: all 1s ease;
  transition: all 1s ease;
}


.container__link {
  display: flex;
  text-decoration: none;
}

.media {
  flex: 6;
  background-color: #222222;
}

img {
  display: block;
  width: 100%;
  height: 450px;
  opacity: 1;
  -webkit-transition: all 1s ease;
  -moz-transition: all 1s ease;
  -o-transition: all 1s ease;
  -ms-transition: all 1s ease;
  transition: all 1s ease;
}

.container:hover .media img {
  opacity: 0.3;
}


.description {
  flex: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  -moz-transition: all 1s ease;
  -o-transition: all 1s ease;
  -ms-transition: all 1s ease;
  transition: all 1s ease;
  background-color: #ffffff;
  color: #222222;
}

.container:hover .description {
  background-color: #222222;
  color: #ffffff;
}

p {
  padding: 0;
  margin: 0;
}
&#13;
&#13;
&#13;