7.纯 CSS 创作一个 3D 文字跑马灯特效


原文地址https://segmentfault.com/a/1190000014663038

感想:简单的从右到左动画

HTML代码:

<div class="box">
       <div class="inner">
            <span>Hello World</span>
       </div>
       <div class="inner">
            <span>Hello World</span>
       </div>
</div>

CSS代码:

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
/*让 两个 inner 水平排列 */
.box{
    display: flex;
}
.box .inner {
    width: 200px;
    height: 100px;
    line-height: 100px;
    font-size: 32px;
    font-family: sans-serif;
    font-weight: bold;
    /* 不换行 */
    white-space: nowrap;
    overflow: hidden;
}
.box .inner:first-child {
    background-color: indianred;
    color: darkred;
    /* 改变被转换元素的位置 */
    transform-origin: left;
    /* perspective 属性指定了观察者与z=0平面的距离,使具有三维位置变换的元素产生透视效果 */
    transform: perspective(300px) rotateY(-67.3deg);
}

.box .inner:last-child {
    background-color: lightcoral;
    color: antiquewhite;
    transform-origin: right;
    transform: perspective(300px) rotateY(67.3deg);
}
.box .inner span {
    position: absolute;
    animation: marquee 5s linear infinite;
}
.box .inner:first-child span {
    /*     规定动画何时开始。默认是 0。 */
    animation-delay: 2.5s;
    /* 个人认为是 left: 100%; 在右边 */
    left: 100%;
}
/* 动画从右到左 */
@keyframes marquee {
    from {
        left: 100%;
    }
    to {
        left: -100%;
    }
}

优质内容筛选与推荐>>
1、jquery $(document).ready() 与window.onload的区别
2、面向对象DAO模式
3、GCC 中文手册
4、form and basic
5、关于MySql连接数据库的方法


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn