CSS3淡入淡出在iOS设备上无法正常运行

时间:2015-10-02 00:46:33

标签: ios css css3 css-animations

尝试获取以下内容,它似乎可以在桌面上运行,也适用于移动设备,但我看到的只是白色。所以淡入永远不会发生。这是我的HTML:

<a href="https://thecleverroot.com/meet-your-makers-hudson-valley-foie-gras/" title="Folio: Meet Your Makers" class="feature-link">
<section class="feature fade-in one" style="background: linear-gradient( rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.35) ), url(https://thecleverroot.com/wp-content/uploads/header-hudson-valley-foie-gras.jpg ) no-repeat top center!important; background-size: cover!important;">
<section class="feature-caption"><p class="category-link">Growers</p><h2>Folio: Meet Your Makers </h2><p>Jenny Chamberlain, Chef of Product Development for Hudson Valley Foie Gras, Ferndale, NY</p><p class="read-more">Read</p></section></section>
</a>

这就是CSS:

.fade-in.one { -webkit-animation-delay: 1.25s; -moz-animation-delay: 1.25s; -o-animation-delay: 1.25s; animation-delay: 1.25s; }
.fade-in { opacity: 0; -webkit-animation: 1s ease-in 0s normal forwards 1 running fadeIn; -moz-animation: 1s ease-in 0s normal forwards 1 running fadeIn; -o-animation: 1s ease-in 0s normal forwards 1 running fadeIn; animation: 1s ease-in 0s normal forwards 1 running fadeIn; }
 body.home a.feature-link { text-decoration: none; }
.feature-caption h2 { font-size: 64px; line-height: .75em; margin: .25em 0; }
.category-link {
    background: #000;
    border-radius: 14px;
    display: inline-block;
    margin: 0;
    padding: 0 20px;
    min-width: 90px;
    height: 31px;
    line-height: 31px;
    color: #FFF;
    font-size: 14px;
    text-align: center;
    font-weight: 400;
    text-transform: uppercase;
}

CodePen:http://codepen.io/anon/pen/ojZXNy

1 个答案:

答案 0 :(得分:1)

我在CodePen上尝试了你的代码,但它也无法在桌面上运行(我在Mac OS Yosemite上测试了最新的Chrome和Safari)。

如果您希望在加载HTML页面后淡入其中,可以这样做:

<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
            .faded-out {
                opacity: 0;
            }
            .fade-in {
                opacity: 1;
                transition: opacity 1s ease-in-out;
                -moz-transition: opacity 1s ease-in-out;
                -webkit-transition: opacity 1s ease-in-out;
            }
            #fadeInContainer {
                background: url(https://thecleverroot.com/wp-content/uploads/header-hudson-valley-foie-gras.jpg);
                padding: 60px;
            }
        </style>
        <script type="text/javascript">
            window.onload = function () {
                document.getElementById("fadeInContainer1").className = "fade-in";
                document.getElementById("fadeInContainer2").className = "fade-in"
            }
        </script>
    </head>
    <body>
        <a href="https://thecleverroot.com/meet-your-makers-hudson-valley-foie-gras/" title="Folio: Meet Your Makers" class="feature-link">
            <section id="fadeInContainer1" class="faded-out">
                <h1>Content 1</h1>
            </section>
            <section id="fadeInContainer2" class="faded-out">
                <h1>Content2</h1>
            </section>
        </a>
    </body>
</html>

有2个CSS类:.faded-out(在加载页面时隐藏内容)和fade-in(内容淡化)。

最初内容具有faded-out类。加载页面后,我们将CSS类切换到fade-in以淡入内容。这是通过javascript完成的。​​

编辑:我现在按照您的评论中的要求淡出两个部分