gpt4 book ai didi

html - 如何在css中设置纵向和横向媒体查询?

转载 作者:技术小花猫 更新时间:2023-10-29 11:50:14 27 4
gpt4 key购买 nike

这是我的媒体查询:

@media screen and (min-device-width: 768px) and (max-device-width: 1824px) and (orientation : portrait){
.hidden-desktop {
display: inherit !important;
}
.visible-desktop {
display: none !important ;
}
.visible-tablet {
display: inherit !important;
}
.hidden-tablet {
display: none !important;
}
}

@media screen and (min-device-width: 768px) and (max-device-width: 1824px) and (orientation : landscape){
.hidden-desktop {
display: inherit !important;
}
.visible-desktop {
display: none !important ;
}
.visible-tablet {
display: inherit !important;
}
.hidden-tablet {
display: none !important;
}
}
@media screen and (max-device-width: 767px) and (orientation: portrait) {
.hidden-desktop {
display: inherit !important;
}
.visible-desktop {
display: none !important;
}
.visible-phone {
display: inherit !important;
}
.hidden-phone {
display: none !important;
}
}
@media screen and (max-device-width: 767px) and (orientation: landscape) {
.hidden-desktop {
display: inherit !important;
}
.visible-desktop {
display: none !important;
}
.visible-phone {
display: inherit !important;
}
.hidden-phone {
display: none !important;
}
}

但是在平板电脑中,如果是横屏模式,这个div会显示

 .visible-tablet {
display: inherit !important;
}

如果它处于纵向模式,则显示此 div

.visible-phone {
display: inherit !important;
}

我希望这个 div .visible-tablet 在我将平板电脑切换到自动旋转模式(适用于纵向和横向)时始终显示

但是我使用了纵向和横向条件,但我仍然面临这个问题。有什么意见吗?

最佳答案

可以这么简单。

@media (orientation: landscape) {

}

关于html - 如何在css中设置纵向和横向媒体查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26861189/

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