CSS 媒体查询未显示在 chrome 检查器中
CSS media queries not showing up in chrome inspector
首先,我不得不说我已经检查了关于这个问题的其他 SO 问题(比如 this and this),我相信我的问题与那些问题不同,并且这个问题不是那些问题的重复.
我的 CSS 文件中有一些媒体查询,如下所示:
@media only screen and (max-width: 767px) { /*css here*/}
当我检查 chrome 检查器时,我可以看到那些 CSS 角色从未应用于所需的元素。我尝试在检查器模式下调整屏幕大小,但那些 CSS 角色仍然不适用。知道什么可能导致这里的问题吗?
编辑
这是我使用的 CSS 的整个块。我正在使用 SCSS 语法,我可以看到生成的 CSS 角色完全没问题,我得到了 filter-title-responsive
class.
的正确角色
.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;
}
}
}
添加:<meta name="viewport" content="width=device-width, initial-scale=1.0">
视口元素向浏览器提供有关如何控制页面尺寸和缩放比例的说明。
width=device-width 部分设置页面的宽度以跟随设备的屏幕宽度(这将因设备而异)。
initial-scale=1.0 部分设置浏览器首次加载页面时的初始缩放级别。
我注意到媒体查询适用于非常大的屏幕尺寸,~1200-1700px,并且 OP 在 Chrome 中使用开发工具进行测试。
我指出了这一点,OP 发现他的响应模式没有正确地模仿大屏幕尺寸,所以事实证明媒体查询按预期工作。
一些资源作为故障排除 Chrome 的开发工具的起点:https://developers.google.com/web/tools/chrome-devtools/device-mode#viewport
他们有一个断点视图,可以直观地标出断点的位置,这可能会有所帮助。
我尝试通过在 chrome 的开发者工具中更改视口的大小来测试不同的屏幕尺寸并应用媒体查询,如下所示:
显然,这不是媒体查询的工作方式,您需要调整浏览器的大小 以针对不同的屏幕尺寸测试不同的媒体查询!
删除“仅屏幕和”
首先,我不得不说我已经检查了关于这个问题的其他 SO 问题(比如 this and this),我相信我的问题与那些问题不同,并且这个问题不是那些问题的重复.
我的 CSS 文件中有一些媒体查询,如下所示:
@media only screen and (max-width: 767px) { /*css here*/}
当我检查 chrome 检查器时,我可以看到那些 CSS 角色从未应用于所需的元素。我尝试在检查器模式下调整屏幕大小,但那些 CSS 角色仍然不适用。知道什么可能导致这里的问题吗?
编辑
这是我使用的 CSS 的整个块。我正在使用 SCSS 语法,我可以看到生成的 CSS 角色完全没问题,我得到了 filter-title-responsive
class.
.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;
}
}
}
添加:<meta name="viewport" content="width=device-width, initial-scale=1.0">
视口元素向浏览器提供有关如何控制页面尺寸和缩放比例的说明。
width=device-width 部分设置页面的宽度以跟随设备的屏幕宽度(这将因设备而异)。
initial-scale=1.0 部分设置浏览器首次加载页面时的初始缩放级别。
我注意到媒体查询适用于非常大的屏幕尺寸,~1200-1700px,并且 OP 在 Chrome 中使用开发工具进行测试。
我指出了这一点,OP 发现他的响应模式没有正确地模仿大屏幕尺寸,所以事实证明媒体查询按预期工作。
一些资源作为故障排除 Chrome 的开发工具的起点:https://developers.google.com/web/tools/chrome-devtools/device-mode#viewport
他们有一个断点视图,可以直观地标出断点的位置,这可能会有所帮助。
我尝试通过在 chrome 的开发者工具中更改视口的大小来测试不同的屏幕尺寸并应用媒体查询,如下所示:
显然,这不是媒体查询的工作方式,您需要调整浏览器的大小 以针对不同的屏幕尺寸测试不同的媒体查询!
删除“仅屏幕和”