【问题标题】:How to position awesome font on img and mimic hover properties如何在 img 上放置很棒的字体并模仿悬停属性
【发布时间】:2017-08-31 18:04:22
【问题描述】:

我想将社交媒体图标放在照片标题旁边的图像下方。即脸书、推特、Soundcloud 和 Instagram。当图像悬停时,我希望社交媒体图标随图像一起旋转。

HTML

<div class="polaroid-images">          
    <a href="" title="Alex" ><img height="200" src="Alexandra.jpg" alt="Island" title="Alex" class=fishes /></a>
    <i class="fa fa-facebook fa-3x"></i>
</div>  

CSS

.polaroid-images a
{
    background: white;
    display: inline;
    float: left;
    margin: 0 15px 70px;
    padding: 10px 10px 25px;
    text-align: center;
    text-decoration: none;
    -webkit-box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
    -moz-box-shadow: 0 4px 6px rgba(0,0,0,.3);
    box-shadow: 0 4px 6px rgba(0,0,0,.3);
    -webkit-transition: all .15s linear;
    -moz-transition: all .15s linear;
    transition: all .15s linear;
    z-index:0;
    position:relative;
}

.polaroid-images a, :after {
   color: #333;
   font-size: 20px;
   content: attr(title);
   position: relative;
   top:15px;
}

.polaroid-images img { 
   display: block; 
   width: inherit; 
}


.polaroid-images a, i:nth-child(3n) { 
    -webkit-transform: rotate(-24deg);  
    -moz-transform: rotate(-24deg); 
    transform: rotate(-24deg); 
}


.polaroid-images a:hover{
   -webkit-transform: rotate(0deg); 
   -moz-transform: rotate(0deg);
   transform: rotate(0deg);
   -webkit-transform: scale(1.2); 
   -moz-transform: scale(1.2);
   transform: scale(1.2);
   z-index:10;
   -webkit-box-shadow: 0 10px 20px rgba(0, 0, 0, .7);
   -moz-box-shadow: 0 10px 20px rgba(0,0,0,.7);
   box-shadow: 0 10px 20px rgba(0,0,0,.7);
}

.polaroid-images i { 
   z-index: 11;
   padding 30px 25px 15px;
   margin-right: 10px 22px 30px ;
   position: absolute;
   top: 25%;  
   left: 25%;
   transform: translate(1%, 1%);    
   overflow: hidden; 
}

【问题讨论】:

    标签: javascript jquery html css image


    【解决方案1】:

    只需将悬停时的相同过渡添加到 i.像这样:

    .polaroid-images:hover i {
        -webkit-transition: all .15s linear;
        -moz-transition: all .15s linear;
        transition: all .15s linear;
    }
    

    【讨论】:

      【解决方案2】:

      将其放入a 并设置其样式,类似于设置:after 的样式,其中包含title 的图像

      .polaroid-images a {
        background: white;
        display: inline;
        float: left;
        margin: 0 15px 70px;
        padding: 10px 10px 25px;
        text-align: center;
        text-decoration: none;
        -webkit-box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
        -moz-box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
        box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
        -webkit-transition: all .15s linear;
        -moz-transition: all .15s linear;
        transition: all .15s linear;
        z-index: 0;
        position: relative;
      }
      
      .polaroid-images a,
      :after {
        color: #333;
        font-size: 20px;
        content: attr(title);
        position: relative;
        top: 15px;
      }
      
      .polaroid-images img {
        display: block;
        width: inherit;
      }
      
      .polaroid-images a,
      i:nth-child(3n) {
        -webkit-transform: rotate(-24deg);
        -moz-transform: rotate(-24deg);
        transform: rotate(-24deg);
      }
      
      .polaroid-images a:hover {
        -webkit-transform: rotate(0deg);
        -moz-transform: rotate(0deg);
        transform: rotate(0deg);
        -webkit-transform: scale(1.2);
        -moz-transform: scale(1.2);
        transform: scale(1.2);
        z-index: 10;
        -webkit-box-shadow: 0 10px 20px rgba(0, 0, 0, .7);
        -moz-box-shadow: 0 10px 20px rgba(0, 0, 0, .7);
        box-shadow: 0 10px 20px rgba(0, 0, 0, .7);
      }
      
      .polaroid-images i {
        position: relative;
        font-size: 1em;
        top: 15px;
        margin-right: .5em;
        color: #3b5998;
      }
      <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
      <div class="polaroid-images">
        <a href="" title="Alex"><img height="200" src="http://kenwheeler.github.io/slick/img/fonz1.png" alt="Island" title="Alex" class=fishes /><i class="fa fa-facebook fa-3x"></i></a>
      </div>

      【讨论】:

      • 我如何将 FB 图标变成链接?当我尝试时,它会将其推出图片框架。
      猜你喜欢
      • 1970-01-01
      • 2021-11-07
      • 2016-12-26
      • 2023-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-08
      • 1970-01-01
      相关资源
      最近更新 更多