gpt4 book ai didi

html - css media 不适用于浏览器大小,但适用于缩放或响应式设计 View

转载 作者:行者123 更新时间:2023-11-28 05:38:53 26 4
gpt4 key购买 nike

我有一个奇怪的问题。当我调整浏览器的窗口大小时,我的媒体查询不起作用,但它可以缩放。它也适用于 firefox 的响应式设计 View 。这是我的 ccs 媒体查询:

https://jsfiddle.net/5n9kv2g5/1/

html:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv=X-UA-Compatible content="IE=edge">

<title></title>
<meta name="description" content="">
<meta name="author" content="">

<link rel="stylesheet" href="css/style.css">


<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

<body>
<div class="row">
<div class="col-1">

</div>
<div class="col-2">

</div>
</div>
</body>
</html>

CSS:

body{
margin:auto;
}
a{
text-decoration: none;
}
.box{
position:absolute;
top:7rem;
height: 27rem;
}
.col-1{
width: 60%;
float:left;
position: relative;
background: #262626;
height: 40rem;
min-height: 100vh;
}
.col-2{
width: 40%;
float: left;
background: #303030;
position: relative;
height: 40rem;
min-height: 100vh;
}


/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 479px) {
/* Styles */

.col-1{
display: none;
}
.col-2{
background:#303030 url("../images/logo.png") top center no-repeat;
-webkit-background-size:50%;
background-size:30%;
width: 100%;
height: 32rem;
}

}
@media only screen and (min-device-width : 480px) and (max-device-width : 639px) {
/* Styles */

.col-1{
display: none;
}
.col-2{
background:#303030 url("../images/logo.png") top center no-repeat;
-webkit-background-size:50%;
background-size:30%;
width: 100%;
height: 34rem;
}
}
@media only screen and (min-device-width : 640px) and (max-device-width : 767px) {
/* Styles */

.col-1{
display: none;
}
.col-2{
background:#303030 url("../images/logo.png") top center no-repeat;
-webkit-background-size:50%;
background-size:30%;
width: 100%;
height: 35rem;
}

}

@media only screen and (min-device-width : 768px) and (max-device-width : 1023px) {
.col-1{
width: 100%;
height: 33rem;
min-height: 0;
}

.box{
top:8rem;
height: 25rem;
}

.col-2{
width: 100%;
height: 30rem;
}

}

最佳答案

编辑/新答案:

使用这个

@media only screen and (min-width : 320px) and (max-width : 479px)

而不是这个

@media only screen and (min-device-width : 320px) and (max-device-width : 479px)

(在所有其他部分中也是如此 - min-width 而不是 min-device-width 等)

https://jsfiddle.net/1wbjp0pp/

关于html - css media 不适用于浏览器大小,但适用于缩放或响应式设计 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38027187/

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