gpt4 book ai didi

css - 为什么在方向改变时不应用 css?

转载 作者:太空宇宙 更新时间:2023-11-04 13:09:45 27 4
gpt4 key购买 nike

我正在使用媒体查询。我的设备宽度为 360,高度为:640。实际上,当方向改变时,我添加了边框来检查是否应用了 css。

但是当我改变方向时它只显示红色边框。为什么不显示其他边框?

@media screen and (max-width: 360px), screen and (max-height: 640px)and (orientation: portrait) {
.subcontent_h {
height: 200px;
overflow: auto;
margin-top: 10px;
border: 1px solid deeppink !important;
}
}

@media screen and (max-width: 640px) , screen and (max-height: 360px)and (orientation: landscape) {
.subcontent_h {
height: 200px;
overflow: auto;
margin-top: 10px;
border: 1px solid red !important;
}
}

最佳答案

Order of Specification: As a last resort, when all other conflict resolution specifications cannot determine which style should take precedence, the last style specified will be the style used.

.subcontent_h{
height: 200px;
overflow: auto;
margin-top: 10px;
}

@media screen and (max-width: 640px) , screen and (max-height: 360px)and (orientation: landscape) {
.subcontent_h {
border: 1px solid red;
}
}

@media screen and (max-width: 360px), screen and (max-height: 640px)and (orientation: portrait) {
.subcontent_h {
border: 1px solid black;
}
}

DEMO

关于css - 为什么在方向改变时不应用 css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24778091/

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