如何在图像图标上设置鼠标效果

时间:2018-12-01 17:34:43

标签: html5 css3

我正在尝试与此link的发现字段中的与我们联系按钮一样的鼠标效果。但是我不能使用相同的系统,并且标题不能在按钮的右侧对齐。有人可以帮我做同样的发现部分,例如列表[link][1]吗?

    <div>
   <a href="#">
   <figure> <img src="http://demo.mofizagrofood.com/wp-content/uploads/2018/11/ph2.png" alt="image"> </figure>

  </a> 
  <h2>
  Contact Us 
  </h2>
  </div>

figure{
    display:block;
    width:80px;
    height: 80px;
    border-radius: 50px;
    font-size: 40px;
    text-align: center;
    margin-right: 10px;
    background: #fff;
    line-height: 1.7em;
}

figure img{
   display:inline-block;
   width: 60px;
   height: auto;
}

演示Link

1 个答案:

答案 0 :(得分:0)

'transform:translateY'使图像上下滑动。父级上的“ display:flex”使其子级从左到右对齐。尝试这个。 https://codepen.io/hridoy569/pen/WYPXNj

<div class="box">
   <a href="#" >
   <figure> 
     <img class="img1" src="" alt="image1"> 
     <img class="img2" src="" alt="image2"> 
   </figure>
  </a> 
  <h2> Contact Us  </h2>
</div>


body{
  background: White;
}

.box{
  width: 350px;
  height: 80px;
  background: #f5f5f5;
  display: flex;
  overflow: hidden;
}
.box h2{

}

figure{
    width:80px;
    height: 80px;
    border-radius: 50px;
    font-size: 20px;
    text-align: center;
    margin: 0 10px 0 10px;
    background: #ccc;
}

figure img{
   width: 80px;
   height: 80px;
}

.box:hover .img1{
              transform: translateY(-100%);
            transition: transform 0.6s ease;
}

.box:not( :hover ) .img1{ 
              transform: translateY(0%);
            transition: transform 0.6s ease;
}
.box:hover .img2{
              transform: translateY(-100%);
            transition: transform 0.6s ease;
}

.box:not( :hover ) .img2{ 
              transform: translateY(0%);
            transition: transform 0.6s ease;
}