我的CSS动画无法在iOS中使用 [英] My CSS animations are not working in iOS

查看:860
本文介绍了我的CSS动画无法在iOS中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请查看 http://facelesstolegendary.com

我在这里查看了几篇文章,发现我需要在转换中添加 -webkit-前缀,等等。

I looked at several posts here and saw that I need to add the -webkit- prefix to my transforms, etc.

我这样做了,但是在iOS上仍然不起作用。它可以在我的桌面浏览器上运行。

I did that, but it still does not work on iOS. It does work on my desktop browsers.

以下是相关代码:

.cb-slideshow,
.cb-slideshow:after { 
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0px;
    left: 0px;
    z-index: 0; 
}
.cb-slideshow:after { 
    content: '';
    background: transparent url(pattern.png) repeat top left; 
}

.cb-slideshow li span { 
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0px;
    left: 0px;
    color: transparent;
    background-size: cover;
    background-position: 50% 50%;
    background-repeat: none;
    opacity: 0;
    -webkit-opacity: 0;
    z-index: 0;
    animation: imageAnimation 36s linear infinite 0s; 
    -webkit-animation: imageAnimation 36s linear infinite 0s; 
}

.cb-slideshow li div { 
    z-index: 1000;
    position: absolute;
    bottom: 30px;
    left: 0px;
    width: 100%;
    text-align: center;
    opacity: 0;
    -webkit-opacity: 0;
    color: #fff;
    animation: titleAnimation 36s linear infinite 0s; 
    -webkit-animation: titleAnimation 36s linear infinite 0s; 
}
.cb-slideshow li div h3 { 
    font-family: 'BebasNeueRegular', 'Arial Narrow', Arial, sans-serif;
    font-size: 240px;
    padding: 0;
    line-height: 200px; 
}

.cb-slideshow li:nth-child(1) span { 
    background-image: url(faceless.jpg) 
}
.cb-slideshow li:nth-child(2) span { 
    background-image: url(legendary.jpg);
    animation-delay: 6s; 
    -webkit-animation-delay: 6s; 
}
.cb-slideshow li:nth-child(3) span { 
    background-image: url(faceless.jpg);
    animation-delay: 12s; 
    -webkit-animation-delay: 12s; 
}
.cb-slideshow li:nth-child(4) span { 
    background-image: url(legendary.jpg);
    animation-delay: 18s; 
    -webkit-animation-delay: 18s; 
}
.cb-slideshow li:nth-child(5) span { 
    background-image: url(faceless.jpg);
    animation-delay: 24s; 
    -webkit-animation-delay: 24s; 
}
.cb-slideshow li:nth-child(6) span { 
    background-image: url(legendary.jpg);
    animation-delay: 30s; 
    -webkit-animation-delay: 30s; 
}

.cb-slideshow li:nth-child(2) div { 
    animation-delay: 6s; 
    -webkit-animation-delay: 6s; 
}
.cb-slideshow li:nth-child(3) div { 
    animation-delay: 12s; 
    -webkit-animation-delay: 12s; 
}
.cb-slideshow li:nth-child(4) div { 
    animation-delay: 18s; 
    -webkit-animation-delay: 18s; 
}
.cb-slideshow li:nth-child(5) div { 
    animation-delay: 24s; 
    -webkit-animation-delay: 24s; 
}
.cb-slideshow li:nth-child(6) div { 
    animation-delay: 30s; 
    -webkit-animation-delay: 30s; 
}

.no-cssanimations .cb-slideshow li span{
	opacity: 1;
	-webkit-opacity: 1;
}

@media screen and (max-width: 1140px) { 
    .cb-slideshow li div h3 { font-size: 140px }
}
@media screen and (max-width: 600px) { 
    .cb-slideshow li div h3 { font-size: 80px }
}

@keyframes imageAnimation { 
	0% {
	    opacity: 0;
	    -webkit-opacity: 0;
	    animation-timing-function: ease-in;
	    -webkit-animation-timing-function: ease-in;
	}
	8% {
	    opacity: 1;
	    -webkit-opacity: 1;
	    transform: scale(1.05);
	    -webkit-transform: scale(1.05);
	    animation-timing-function: ease-out;
	    -webkit-animation-timing-function: ease-out;
	}
	17% {
	    opacity: 1;
	    -webkit-opacity: 1;
	    transform: scale(1.1) rotate(3deg);
	    -webkit-transform: scale(1.1) rotate(3deg);
	}
	25% {
	    opacity: 0;
	    -webkit-opacity: 0;
	    transform: scale(1.1) rotate(3deg);
	    -webkit-transform: scale(1.1) rotate(3deg);
	}
	100% { 
		opacity: 0 
		-webkit-opacity: 0 
	}
}

<ul class="cb-slideshow">
    <li>
        <span>Image 01</span>
        <div>
        </div>
    </li>
    <li>
        <span>Image 02</span>
        <div>
        </div>
    </li>
    <li>
        <span>Image 03</span>
        <div>
        </div>
    </li>
    <li>
        <span>Image 04</span>
        <div>
        </div>
    </li>
    <li>
        <span>Image 05</span>
        <div>
        </div>
    </li>
    <li>
        <span>Image 06</span>
        <div>
        </div>
    </li>
</ul>

推荐答案

您需要为 @keyframes 加上 -webkit-前缀,并包含 -webkit-在其中添加了固定的动画和过渡效果,而不是将它们包含在原始的 @keyframes

You need to prefix your @keyframes with -webkit-, and include the -webkit-prefixed animations and transitions there, instead of including them in your original @keyframes:

@keyframes imageAnimation { 
    0% {
        opacity: 0;
        -webkit-opacity: 0;
        animation-timing-function: ease-in;
        -webkit-animation-timing-function: ease-in;
    }

成为:

@-webkit-keyframes imageAnimation {
    0% {
        -webkit-opacity: 0;
        -webkit-animation-timing-function: ease-in;
    }

@keyframes imageAnimation {
    0% {
        opacity: 0;
        animation-timing-function: ease-in;
    }

,依此类推。

这篇关于我的CSS动画无法在iOS中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆