首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IE中的文本转换动画效果问题

IE中的文本转换动画效果问题
EN

Stack Overflow用户
提问于 2014-12-08 17:18:31
回答 3查看 1.3K关注 0票数 0

下面的代码在大多数浏览器中显示动画文本,除了运行IE的IE之外,但您看不到它。我能得到一些关于如何解决这个问题的指导吗?

请参考此链接查看示例> http://jsfiddle.net/pherrera/posvken7/

这是密码:

代码语言:javascript
复制
<div class="container">
    <div id="background" class="card">
        <div class="sp-container">
            <div class="sp-content">
                <div class="sp-globe"></div>
                <h3 class="frame-1">message 1</h3>
                <h3 class="frame-2">message 2</h3>
                <h3 class="frame-3">message 3</h3>
                <h3 class="frame-4">Now!</h2>
                <h3 class="frame-5">
                    <span>this</span> <span>is</span> <span>a message</span>
                </h3>
                <a class="sp-circle-link" href="#">again!</a>
            </div>
        </div>
    </div>
</div>
代码语言:javascript
复制
body, html {
    background-color: #282828;
    display: table;
    height: 100%;
    width: 100%;
}

.container {
    display: table-cell;
    vertical-align: middle;
}

.card {
    border-radius: 2px 2px 2px 2px;
    -moz-border-radius: 2px 2px 2px 2px;
    -webkit-border-radius: 2px 2px 2px 2px;
    border: 0px none;
    -webkit-box-shadow: 0px 0px 75px 0px rgba(255, 255, 255, 0.1);
    -moz-box-shadow: 0px 0px 75px 0px rgba(255, 255, 255, 0.1);
    box-shadow: 0px 0px 75px 0px rgba(255, 255, 255, 0.1);
}

#background {
    width: 600px;
    height: 500px;
    margin: 0 auto;
    background: rgba(92, 92, 92, 1);
    background: -moz-radial-gradient(center, ellipse cover, rgba(92, 92, 92, 1) 0%, rgba(59, 59, 59, 1) 100%);
    background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, rgba(92, 92, 92, 1)), color-stop(100%, rgba(59, 59, 59, 1)));
    background: -webkit-radial-gradient(center, ellipse cover, rgba(92, 92, 92, 1) 0%, rgba(59, 59, 59, 1) 100%);
    background: -o-radial-gradient(center, ellipse cover, rgba(92, 92, 92, 1) 0%, rgba(59, 59, 59, 1) 100%);
    background: -ms-radial-gradient(center, ellipse cover, rgba(92, 92, 92, 1) 0%, rgba(59, 59, 59, 1) 100%);
    background: radial-gradient(ellipse at center, rgba(92, 92, 92, 1) 0%, rgba(59, 59, 59, 1) 100%);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5c5c5c', endColorstr='#3b3b3b', GradientType=1);
}

a {
    text-decoration: none;
}

h1.main, p.demos {
    -webkit-animation-delay: 18s;
    -moz-animation-delay: 18s;
    -ms-animation-delay: 18s;
    animation-delay: 18s;
}

.sp-container {
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: -webkit-radial-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3) 35%, rgba(0, 0, 0, 0.7));
    background: -moz-radial-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3) 35%, rgba(0, 0, 0, 0.7));
    background: -ms-radial-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3) 35%, rgba(0, 0, 0, 0.7));
    background: radial-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3) 35%, rgba(0, 0, 0, 0.7));
}

.sp-content {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0px;
    top: 0px;
    z-index: 1000;
}

.sp-container h3 {
    position: absolute;
    top: 50%;
    line-height: 100px;
    height: 90px;
    margin-top: -50px;
    font-size: 60px;
    width: 100%;
    text-align: center;
    color: transparent;
    -webkit-animation: blurFadeInOut 3s ease-in backwards;
    -moz-animation: blurFadeInOut 3s ease-in backwards;
    -ms-animation: blurFadeInOut 3s ease-in backwards;
    animation: blurFadeInOut 3s ease-in backwards;
}

.sp-container h3.frame-1 {
    -webkit-animation-delay: 0s;
    -moz-animation-delay: 0s;
    -ms-animation-delay: 0s;
    animation-delay: 0s;
}

.sp-container h3.frame-2 {
    -webkit-animation-delay: 3s;
    -moz-animation-delay: 3s;
    -ms-animation-delay: 3s;
    animation-delay: 3s;
}

.sp-container h3.frame-3 {
    -webkit-animation-delay: 6s;
    -moz-animation-delay: 6s;
    -ms-animation-delay: 6s;
    animation-delay: 6s;
}

.sp-container h3.frame-4 {
    font-size: 200px;
    -webkit-animation-delay: 9s;
    -moz-animation-delay: 9s;
    -ms-animation-delay: 9s;
    animation-delay: 9s;
}

.sp-container h3.frame-5 {
    -webkit-animation: none;
    -moz-animation: none;
    -ms-animation: none;
    animation: none;
    color: transparent;
    text-shadow: 0px 0px 1px #fff;
}

.sp-container h3.frame-5 span {
    -webkit-animation: blurFadeIn 3s ease-in 12s backwards;
    -moz-animation: blurFadeIn 1s ease-in 12s backwards;
    -ms-animation: blurFadeIn 3s ease-in 12s backwards;
    animation: blurFadeIn 3s ease-in 12s backwards;
    color: transparent;
    text-shadow: 0px 0px 1px #fff;
}

.sp-container h3.frame-5 span:nth-child(2) {
    -webkit-animation-delay: 13s;
    -moz-animation-delay: 13s;
    -ms-animation-delay: 13s;
    animation-delay: 13s;
}

.sp-container h3.frame-5 span:nth-child(3) {
    -webkit-animation-delay: 14s;
    -moz-animation-delay: 14s;
    -ms-animation-delay: 14s;
    animation-delay: 14s;
}

.sp-globe {
    position: absolute;
    width: 282px;
    height: 273px;
    left: 50%;
    top: 50%;
    margin: -137px 0 0 -141px;
    -webkit-animation: fadeInBack 3.6s linear 14s backwards;
    -moz-animation: fadeInBack 3.6s linear 14s backwards;
    -ms-animation: fadeInBack 3.6s linear 14s backwards;
    animation: fadeInBack 3.6s linear 14s backwards;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
    filter: alpha(opacity=30);
    opacity: 0.3;
    -webkit-transform: scale(5);
    -moz-transform: scale(5);
    -o-transform: scale(5);
    -ms-transform: scale(5);
    transform: scale(5);
}

.sp-circle-link {
    position: absolute;
    left: 50%;
    bottom: 100px;
    margin-left: -50px;
    text-align: center;
    line-height: 100px;
    width: 100px;
    height: 100px;
    background: #fff;
    color: #3f1616;
    font-size: 25px;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border-radius: 50%;
    -webkit-animation: fadeInRotate 1s linear 16s backwards;
    -moz-animation: fadeInRotate 1s linear 16s backwards;
    -ms-animation: fadeInRotate 1s linear 16s backwards;
    animation: fadeInRotate 1s linear 16s backwards;
    -webkit-transform: scale(1) rotate(0deg);
    -moz-transform: scale(1) rotate(0deg);
    -o-transform: scale(1) rotate(0deg);
    -ms-transform: scale(1) rotate(0deg);
    transform: scale(1) rotate(0deg);
}

.sp-circle-link:hover {
    background: #85373b;
    color: #fff;
}
/**/
@-webkit-keyframes blurFadeInOut {
    0% {
        opacity: 0;
        text-shadow: 0px 0px 40px #fff;
        -webkit-transform: scale(1.3);
    }

    20%, 75% {
        opacity: 1;
        text-shadow: 0px 0px 1px #fff;
        -webkit-transform: scale(1);
    }

    100% {
        opacity: 0;
        text-shadow: 0px 0px 50px #fff;
        -webkit-transform: scale(0);
    }
}

@-webkit-keyframes blurFadeIn {
    0% {
        opacity: 0;
        text-shadow: 0px 0px 40px #fff;
        -webkit-transform: scale(1.3);
    }

    50% {
        opacity: 0.5;
        text-shadow: 0px 0px 10px #fff;
        -webkit-transform: scale(1.1);
    }

    100% {
        opacity: 1;
        text-shadow: 0px 0px 1px #fff;
        -webkit-transform: scale(1);
    }
}

@-webkit-keyframes fadeInBack {
    0% {
        opacity: 0;
        -webkit-transform: scale(0);
    }

    50% {
        opacity: 0.4;
        -webkit-transform: scale(2);
    }

    100% {
        opacity: 0.2;
        -webkit-transform: scale(5);
    }
}

@-webkit-keyframes fadeInRotate {
    0% {
        opacity: 0;
        -webkit-transform: scale(0) rotate(360deg);
    }

    100% {
        opacity: 1;
        -webkit-transform: scale(1) rotate(0deg);
    }
}
/**/
@-moz-keyframes blurFadeInOut {
    0% {
        opacity: 0;
        text-shadow: 0px 0px 40px #fff;
        -moz-transform: scale(1.3);
    }

    20%, 75% {
        opacity: 1;
        text-shadow: 0px 0px 1px #fff;
        -moz-transform: scale(1);
    }

    100% {
        opacity: 0;
        text-shadow: 0px 0px 50px #fff;
        -moz-transform: scale(0);
    }
}

@-moz-keyframes blurFadeIn {
    0% {
        opacity: 0;
        text-shadow: 0px 0px 40px #fff;
        -moz-transform: scale(1.3);
    }

    100% {
        opacity: 1;
        text-shadow: 0px 0px 1px #fff;
        -moz-transform: scale(1);
    }
}

@-moz-keyframes fadeInBack {
    0% {
        opacity: 0;
        -moz-transform: scale(0);
    }

    50% {
        opacity: 0.4;
        -moz-transform: scale(2);
    }

    100% {
        opacity: 0.2;
        -moz-transform: scale(5);
    }
}

@-moz-keyframes fadeInRotate {
    0% {
        opacity: 0;
        -moz-transform: scale(0) rotate(360deg);
    }

    100% {
        opacity: 1;
        -moz-transform: scale(1) rotate(0deg);
    }
}
/**/
@keyframes blurFadeInOut {
    0% {
        opacity: 0;
        text-shadow: 0px 0px 40px #fff;
        transform: scale(1.3);
    }

    20%, 75% {
        opacity: 1;
        text-shadow: 0px 0px 1px #fff;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        text-shadow: 0px 0px 50px #fff;
        transform: scale(0);
    }
}

@keyframes blurFadeIn {
    0% {
        opacity: 0;
        text-shadow: 0px 0px 40px #fff;
        transform: scale(1.3);
    }

    50% {
        opacity: 0.5;
        text-shadow: 0px 0px 10px #fff;
        transform: scale(1.1);
    }

    100% {
        opacity: 1;
        text-shadow: 0px 0px 1px #fff;
        transform: scale(1);
    }
}

@keyframes fadeInBack {
    0% {
        opacity: 0;
        transform: scale(0);
    }

    50% {
        opacity: 0.4;
        transform: scale(2);
    }

    100% {
        opacity: 0.2;
        transform: scale(5);
    }
}

@keyframes fadeInRotate {
    0% {
        opacity: 0;
        transform: scale(0) rotate(360deg);
    }

    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-12-11 14:09:24

已完成:

在对网络进行了一些挖掘之后,我成功地添加了一些代码,使其能够在IE上工作(至少IE 11 )。

我几乎不得不增加和摆弄这些台词:

代码语言:javascript
复制
-ms-filter:”progid:DXImageTransform.Microsoft.Alpha(Opacity=0)”;
filter: alpha(opacity=0);
zoom: 1; filter: alpha(opacity=0);

见此处:http://jsfiddle.net/posvken7/8/

票数 0
EN

Stack Overflow用户

发布于 2014-12-08 20:19:20

基本上,这里唯一的问题,现代版本的IE将有一个问题,是渲染一个阴影上的透明元素。这是一个已知的限制,有几个奇怪的地方;如果模糊半径是0,那么文本将是可见的。否则,要投出阴影,文本的颜色需要有点不透明。

在玩了一小段时间之后,我想出了一个可能的解决方案--在你的演示中应该足够了。由于文本阴影已经工作,并且能够从偏移量中定位,所以您可以将元素本身定位到相反的方向:

代码语言:javascript
复制
.blur {
    top: -100vh;
    position: relative;
    text-shadow: 0 100vh 1em #000;
}

为了只显示一个模糊的文本,我们将阴影向下推100 the。这将使其脱离屏幕,因此我们还将抛出阴影的元素推上100 of,从而将模糊的文本恢复到其主机元素的原始位置。

在本例中,我使用的是ga veritcal偏移量,但您可能会发现,对于某些场景来说,这并不理想。例如,您的文档更高,而您的模糊区域更低,您可能会发现横向偏移更好。在这种情况下,可以通过隐藏横向溢出来避免不必要的滚动条:

代码语言:javascript
复制
body {
    overflow-x: hidden;
}

我编写了一个演示小提琴,显示结果在线这里。在构建它时,我确实注意到Chrome当前有一个布局问题,这在调整大小时是很明显的--它看起来vm (可能还有vh)与当前的视口尺寸不同步。如果在项目中出现问题,您可能需要使用另一个单元。

将此效果应用于出现延迟的作品也是可能的。我冒昧地创建了演示这种效果的副手。它的标记非常直接,类似于您已经拥有的内容:

代码语言:javascript
复制
<h1>
    <span>Hello</span> 
    <span>World</span>
</h1>
<h2>
    <span>Additional</span>
    <span>Information</span>
    <span>Provided</span>
    <span>Eventually</span>
</h2>

CSS完成了以下几项任务:

  1. 将文本在<body>中居中(可能仅限于标题)
  2. 将元素定位到屏幕外,并在屏幕上放置文本阴影。
  3. 在各种延迟时动画化text-shadow属性以显示嵌套的<span>元素
代码语言:javascript
复制
body {
    text-align: center;
    font-family: "Segoe UI";
}

span {
    opacity: 0;
    vertical-align: middle;
    text-shadow: 100vw 0 3em #000;
    position: relative; left: -100vw;
    animation: fadein 2s ease-in-out forwards;
}

/* Controls 'Hello' and 'World' */
h1 span:nth-child(1) { animation-delay: 1s; }
h1 span:nth-child(2) { animation-delay: 2s; }

/* Controls 'Stack Overflow is Awesome */
h2 span { animation-delay: 3s; }

@keyframes fadein {
    to { 
        opacity: 1;
        text-shadow: 100vw 0 0 #000;
    }
}

最终的结果是一个平滑的、跨浏览器的、模糊的效果:

票数 2
EN

Stack Overflow用户

发布于 2014-12-08 17:38:15

Css动画、子选择器和渐变在IE7中是受支持的,请查看caniuse.com在每个浏览器/版本中支持什么。

另外,IE中根本不支持过滤器和动画。

哦,它在IE9中被打破了,它能帮助任何人。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27363319

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档