gpt4 book ai didi

html - 为什么这个媒体查询不否决主 CSS

转载 作者:行者123 更新时间:2023-11-28 01:30:13 25 4
gpt4 key购买 nike

我不知道,为什么这个媒体查询没有:

@media only screen and (max-width: 1200px){

.hero-text-box {
width: 100%;
padding: 0 2%;
}
}

不会否决标准样式的 css 女巫看起来像这样

.hero-text-box {
position: absolute;
width: 1140px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

当我在屏幕尺寸低于 1200 像素时查看 google chrome 开发者工具时,填充有效,但不是 100% 宽度。 IT只是交叉了。

最佳答案

重要的是这些规则在您的 CSS 中出现的顺序。您应该将媒体查询规则放在常规规则之下:

.hero-text-box {
position: absolute;
width: 1140px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

@media only screen and (max-width: 1200px){
.hero-text-box {
width: 100%;
padding: 0 2%;
}
}

如果这些规则位于单独的文件中,请确保在具有常规样式的文件之后包含带有媒体查询的文件。

关于html - 为什么这个媒体查询不否决主 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30526010/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com