【发布时间】:2020-05-26 11:16:36
【问题描述】:
首先,我必须说我已经检查过有关此问题的其他 SO 问题(例如 this 和 this),并且我相信我的问题与这些问题不同,并且此问题不是这些问题的重复.
我的 CSS 文件中有一些媒体查询,如下所示:
@media only screen and (max-width: 767px) { /*css here*/}
当我检查 chrome 检查器时,我可以看到这些 CSS 角色永远不会应用于所需的元素。我尝试在检查器模式下调整屏幕大小,但这些 CSS 角色仍然不适用。知道什么可能导致这里出现问题吗?
编辑
这是我使用的整个 CSS 块。我正在使用 SCSS 语法,我可以看到生成的 CSS 角色完全没有问题,并且我得到了 filter-title-responsive 类的正确角色。
.filter-panel-container {
@extend %select-input-fix;
@extend %date-input-fix;
width: 100%;
height: auto;
.filter-header-container {
height: 40px;
width: 100%;
border-radius: 5px 5px 0 0;
background-color: $theme_athens_gray_color;
padding-top: 10px;
padding-bottom: 11px;
padding-left: 16px;
display: flex;
flex-direction: row;
justify-content: start;
& * {
color: $theme_gulf_blue_color;
}
i {
margin-top: 2px;
}
.filter-title {
font-family: $Montserrat-font;
font-size: 16px;
font-weight: 500;
line-height: 19px;
margin-left: 5px;
}
.filter-title-responsive {
font-size: 14px;
margin-left: 0;
}
@media screen and (max-width: 1730px) {
.filter-title-responsive {
font-size: 12px;
}
}
@media screen and (max-width: 1370px) {
.filter-title-responsive {
font-size: 10px;
}
}
@media screen and (max-width: 1210px) {
.filter-title-responsive {
font-size: 7px;
}
}
&.filter-header-disable {
border: 1px solid $theme_athens_gray_color;
border-bottom: none;
background-color: white;
color: $theme_athens_gray_color;
}
}
}
【问题讨论】:
-
所以你已经确定你的 html 中有元视口标签,并且你没有通过在 css 中使用它下面的相同选择器来覆盖媒体查询?抱歉,我想问一下。
-
@SydneyY 是的,都选中了。
-
是否应用了同一文件中的其他 css? (证明您的媒体查询在成功加载的样式表中)
-
@SydneyY 是的,该文件中的所有其他 CSS 角色都已应用,但媒体查询中的角色除外。
-
您能否将整个媒体查询块添加到您的问题中,以便我们查看?你可以简化一点,但不要改变太多:)
标签: css sass media-queries