【问题标题】:My CSS animations are not working in iOS我的 CSS 动画在 iOS 中不起作用
【发布时间】:2015-06-06 16:11:36
【问题描述】:

请看http://facelesstolegendary.com

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

我做到了,但它仍然无法在 iOS 上运行。它确实在我的桌面浏览器上工作。

以下是相关代码:

.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>

【问题讨论】:

    标签: html ios css css-animations


    【解决方案1】:

    您需要在您的@keyframes 前面加上-webkit-,并在其中包含带有-webkit-前缀的动画和过渡,而不是将它们包含在您原来的@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;
        }
    

    等等。

    【讨论】:

    • @DanishAdeel 没有关键帧结尾括号,因为那不是关键帧声明的结尾;之后有更多步骤。我只包括了关键帧左括号,因为有必要说明对关键帧声明开头的更改。
    • 我已经尝试了所有这些方法,但仍然无法正常工作,我正在以特定的时间间隔更改内容。在 iPhone 12 Pro (iOS 15) 上测试。 @-webkit-keyframes 改变 { 0% { -webkit-content:"5"; } 34% { -webkit 内容:“7”; } 67% { -webkit 内容:“9”; } 100% { -webkit-content: "5"; } }
    • @ShihabEK content 不是供应商前缀属性。它也只对伪元素有效。
    【解决方案2】:

    -webkit-overflow-scrolling: touch;你是不是在别处写的,试试删。

    【讨论】:

    • 这没有提供问题的答案。要批评或要求作者澄清,请在其帖子下方发表评论。
    猜你喜欢
    • 2014-04-03
    • 2018-10-08
    • 2016-10-22
    • 2018-06-25
    • 2015-10-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多