繁体   English   中英

为什么 CSS 旋转在移动设备上不起作用?

[英]Why is CSS spinning not working on mobile?

我想将下面的图像旋转到 360 度并低于应用于该图像的 css:

<img src="" alt="" />

CSS:

.image {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    margin:-60px 0 0 -60px;
    -webkit-animation:spin 4s linear infinite;
    -moz-animation:spin 4s linear infinite;
    animation:spin 4s linear infinite;
}
@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }

它在桌面上运行良好,但在移动设备上运行不好吗? 如果我做错了什么?

这在移动设备和桌面设备上都适用于我。

.loader {
  position: absolute;
  width: 120px;
  height: 120px;
  left: 0; right: 0;
  top: 0; bottom: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  -webkit-animation: spin 4s linear infinite;
  animation: spin 4s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

您的自旋代码可能不起作用,因为您没有正确编码。 @keyframes动画中存在一些问题。

查看示例

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM