【问题标题】:changing image during flip css animation在翻转 css 动画期间更改图像
【发布时间】:2017-07-27 19:29:00
【问题描述】:

我目前有一个旋转图像,它可以翻转并使用动画 css 在背面书写,但是我想要的是,当图像翻转时,它会随着另一个图像而变化,因此它具有纯色而不是反转版本图片。

CSS

.hover-img {
position: relative;
width: 400px;
height: 300px;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
background:url(bbclike/topright.png);
-webkit-transform:rotateY(180deg);
-webkit-transform-style: preserve-3d;
    line-height:200px;
text-align:center;
font-size:0;

}
.hover-img:hover{
-webkit-transform:rotateY(0deg);
font-size:14px;
color:white;
background-color:#FF0;

}

HTML

<div class="hover-img">
Text Goes Here
</div>

【问题讨论】:

标签: html css animation css-animations


【解决方案1】:

当用户悬停 div 时,只需在悬停部分放置您想要的任何内容...例如:

.hover-img:hover{
background:url(---HERE IMAGE 2---);
font-size:14px;
color:white;
background-color:#FF0;
}

工作小提琴演示here

【讨论】:

    【解决方案2】:

    你可能想试试这个

    http://jsbin.com/tejiduq/1/edit?html,css,output

    更改容器类,以便您可以操作 DOM 类。

    //html 
    <div>
        <i class="icon"></i>
    </div>
    <br>
    <input class="button" type="button" value="flip">
    
    //css
    div{
    }
    .icon {
      display: inline-block;
      width: 30px;
      height: 30px;
      transition: all 0.5s;
    }
    
    div .icon {
        background: url("https://www.w3schools.com/images/compatible_chrome.gif") no-repeat;
    }
    
    div.ie .icon{
      background: url("https://www.w3schools.com/images/compatible_edge.gif") no-repeat;
      transform: scaleX(-1)
    }
    
    //javascript 
    $(".button").click(function() {
      $("div").toggleClass("ie");
    });
    

    希望这对你有用。

    【讨论】:

      猜你喜欢
      • 2021-05-14
      • 2021-11-29
      • 2015-02-08
      • 2015-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多