html - 内联 CSS 图像过渡

标签 html css

我想实现以下效果:在 CSS 下方,悬停时,做一个“老虎机效果”,在垂直旋转木马中滚动图标(请参阅下面的 css 了解详细信息)。 由于我为我的网站使用的托管限制,我不能使用任何外部图标库,所以我想达到同样的效果,将 css 粘贴到 header 中并将其与 img HTML 中的标记。

你能帮我修改这个 css 以便它真正适用于我的图像吗?

感谢大家的包容和帮助。

-webkit-transition:all .3s;
-o-transition:all .3s;
transition:all .3s
}
.btn.social_share:hover .social-media-share-buttons-icon:before {
    top: 40px;
    -webkit-transition: all .3s;
    -o-transition: all .3s;
    transition: all .3s
}
.btn.social_share:hover .social-media-share-buttons-icon:after {
    top: 0;
    -webkit-transition: all .3s;
    -o-transition: all .3s;
    transition: all .3s
}
.btn.social_share:active {
    text-decoration: none!important;
    -webkit-touch-callout: none
}
.btn.social_share:active .social-media-share-buttons-icon {
    background-color: rgba(0, 0, 0, .2);
    -webkit-transition: all .3s;
    -o-transition: all .3s;
    transition: all .3s
}
.btn.social_share:active .social-media-share-buttons-icon:before {
    top: 40px;
    -webkit-transition: all .3s;
    -o-transition: all .3s;
    transition: all .3s
}
.btn.social_share:active .social-media-share-buttons-icon:after {
    top: 0;
    -webkit-transition: all .3s;
    -o-transition: all .3s;
    transition: all .3s
}
.btn.social_share.facebook .social-media-share-buttons-icon:after,
.btn.social_share.facebook .social-media-share-buttons-icon:before {
    content: "\e63f"
}
.btn.social_share.linkedin .social-media-share-buttons-icon:after,
.btn.social_share.linkedin .social-media-share-buttons-icon:before {
    content: "\e631"
}
.btn.social_share.twitter .social-media-share-buttons-icon:after,
.btn.social_share.twitter .social-media-share-buttons-icon:before {
    content: "\e640"
}
@-moz-keyframes fadeBottom {
    0% {
        opacity: 0;
        -ms-transform: translateY(10%);
        -webkit-transform: translateY(10%);
        transform: translateY(10%)
    }

    100% {
        opacity: 1;
        -ms-transform: translateY(0);
        -webkit-transform: translateY(0);
        transform: translateY(0)
    }
}
@-webkit-keyframes fadeBottom {
    0% {
        opacity: 0;
        -ms-transform: translateY(10%);
        -webkit-transform: translateY(10%);
        transform: translateY(10%)
    }

    100% {
        opacity: 1;
        -ms-transform: translateY(0);
        -webkit-transform: translateY(0);
        transform: translateY(0)
    }
}
@-o-keyframes fadeBottom {
    0% {
        opacity: 0;
        -ms-transform: translateY(10%);
        -webkit-transform: translateY(10%);
        transform: translateY(10%)
    }

    100% {
        opacity: 1;
        -ms-transform: translateY(0);
        -webkit-transform: translateY(0);
        transform: translateY(0)
    }
}

根据要求,还添加了 HTML 代码段,目前无法使用上述 css:

<div style="padding: 30px 0; padding-left: 0px; margin-left: 0px; margin-right: 0px; text-align: center">
            <div class="col-xs-12">
                                <ul class="social-media-share-buttons">
                    <li>
    <a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://www.mywebsite.com" class="btn btn-link social_share facebook" rel="nofollow" data-social_name="facebook" data-post_id="" data-social_type="share" data-location="inline">
        <img class="social-media-share-buttons-icon" src="facebook_icon.png">
        <div style="color: #fff; line-height: 2; font-weight: 700;">Facebook</div>
    </a>
</li>   

最佳答案

你不需要动画。只需使用转换和转换就可以了:这里有一些例子:

ul {
  text-align: center;
  padding: 0;
}

li {
  list-style-type: none;
}

a {
  display: inline-block;
  position: relative;
  height: 40px;
  background: #4456aa;
  line-height: 40px;
  overflow: hidden;
  color: white;
  text-decoration: none;
  font-family: sans-serif;
  border: 1px solid transparent;
  transition: all 0.5s ease 0.5s;
}

a div {
  padding: 0 30px;
}

a img {
  transition: all ease 1s;
  position: absolute;
  top: 100%;
  left: 0;
  bottom: 0;
  width: 30px;
  margin: auto;
  opacity: 0;
}

a:hover {
  transition: all ease 0.5s;
}

a:hover {
  background: #ffffff;
  border: 1px solid #000000;
  color: #000000;
}

a:hover img {
  transition: all 0.5s ease 0.5s;
  opacity: 1;
  top: 0;
  bottom: 0;
}
<ul class="social-media-share-buttons">
  <li>
    <a target="_blank"
       href="https://www.facebook.com/sharer/sharer.php?u=https://www.mywebsite.com"
       class="btn btn-link social_share facebook"
       rel="nofollow"
       data-social_name="facebook"
       data-post_id=""
       data-social_type="share"
       data-location="inline">
        <img class="social-media-share-buttons-icon" 
             src="https://image.flaticon.com/icons/png/128/20/20837.png">
        <div>Facebook</div>
    </a>
  </li>
</ul>

关于html - 内联 CSS 图像过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57145343/

相关文章:

javascript - 单击 2 次后,在 javascript 中动态更改高度属性将不起作用。我想连续切换多次,点击一次

html - 需要 Google Apps 脚本和脚本数据库替换示例

html - 使用css Grid时水平滚动条导致垂直滚动条来

css - 在 WordPress 插件中集成 bootstrap 时避免命名空间冲突

html - 在右侧放置一个div

javascript - 检查 ascii 纯文本

javascript - 使用 JS 或 JQuery,使用 jQuery 的 listselect.js 将选择中的所有内容从一个列表移动到 "selected"

css - 旋转 7 次然后缓动

javascript - 计算 div 元素内的行数

html - 容器流体未居中