html - Internet Explorer 媒体查询在不应生效时生效

标签 html css internet-explorer media-queries

我有以下 CSS:

@media all and (max-width: 500px){
    .calendar_head{
        height: 120px;
        line-height: 60px;
    }
}
.calendar_head{
    width: 100%;
    font-weight: 700;
    color: #6a7783;
    text-align: center;
    line-height: 30px;
}

在 Internet Explorer 11(可能还有其他版本)中,首次加载页面时,无论视口(viewport)宽度如何,媒体查询都会生效。只有当页面调整大小时,它才意识到媒体查询不应该生效。

最佳答案

尝试将媒体查询放在正常类状态之后。另外,您也可以尝试为非媒体查询指定一个高度。

.calendar_head{
    width: 100%;
    font-weight: 700;
    color: #6a7783;
    text-align: center;
    line-height: 30px;
    height: auto;
}
@media all and (max-width: 500px){
    .calendar_head{
        height: 120px;
        line-height: 60px;
    }
}

关于html - Internet Explorer 媒体查询在不应生效时生效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29051695/

相关文章:

php - Wordpress Jetpack 共享按钮在自定义主题上显示有趣

jquery - 向下滚动时将 div 词缀动画化到顶部

css - IE7 CSS float 问题

css - IE6 表单/div float 问题

javascript - 在 html 标记中使用冒号并在 javascript 中处理其元素

html - 将鼠标悬停在 div 上时显示文本装饰

html - 每行响应式 Flexbox 元素

jquery - 调用 JQuery 且不回发的 Html 按钮

Javascript smoothscroll 由于某种原因不起作用

html - 离开选项卡时如何清理我的表单