CSS 动画关键帧中断媒体查询

标签 css animation media-queries

在处理页面(在 magento 中)时,我注意到我直接放置在媒体查询上方的动画关键帧破坏了媒体查询。当我切换它们时,一切正常。

为什么会这样?我没有正确关闭关键帧吗?我无法发现错误,是我做错了什么还是这是一个已知问题?

我的 CSS 的底部:

    .shop:hover .imagesub {
    transition: 1s;
    max-height:80px;
}

.tooltip img:hover {
-webkit-animation: 0.5s linear 0s infinite alternate bounce;
     -moz-animation: 0.5s linear 0s infinite alternate bounce;
       -o-animation: 0.5s linear 0s infinite alternate bounce;
          animation: 0.5s linear 0s infinite alternate bounce;
}


@media only screen and (max-width: 1000px) { 
    .infobar {
        background-color: aqua;
    }
    .lefthalf {
        width:100%;
      }
    .righthalf {
        width:100%;
        float:left;
        }
    .shoprow {
        width:100%;
        height:auto;
        }
    .shop {
        width:99%;
        float:left;
        margin-bottom:14px;
    }
    .shop img {
        width:100%;
        height:auto;
        }
    .shopcontainer {
        height:auto;
        }
    .imagetitle {
        left:0px;
        width:100%; }
    .imagesub {
        display:none;
        }
}

@-webkit-keyframes bounce { from { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }
   @-moz-keyframes bounce { from { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }
     @-o-keyframes bounce { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }
        @keyframes bounce { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }

这行得通。 但是当关键帧放在媒体查询上方时,媒体查询不起作用。为什么?

最佳答案

您可能粘贴了一些错误的代码

请注意,您的最后 2 个 css 规则从 {

中丢失
@-webkit-keyframes bounce { from { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }
   @-moz-keyframes bounce { from { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }
     @-o-keyframes bounce { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }
        @keyframes bounce { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }

应该是

@-webkit-keyframes bounce { from { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }
   @-moz-keyframes bounce { from { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }
     @-o-keyframes bounce { from { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }
        @keyframes bounce { from { width:30px; height:40px; margin-left:0; } to { width:35px; height:45px; margin-left:-1px;}  }

关于CSS 动画关键帧中断媒体查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37616123/

相关文章:

html - 填充在我的 <ul> 上创建了奇怪的黑线

html - 按钮不会在所有分辨率下左对齐

jquery - 需要根据 CheckBox 选中状态在切换 DiV 中设置 CssClass

ios - Swift:如何设置在 CAKeyFrameAnimation 完成时发生的 Action

c - C 中的动画文本图像

JavaScript 碰撞检测似乎不起作用?

html - 如何在响应式标题中将 Logo 居中

javascript - jQuery .height() 属性不起作用

html - 媒体查询在 Firefox 和 IE 中的工作方式不同

css - 水平菜单和下拉菜单之间的切换