我正在学习HTML,CSS和响应式的基础知识。我已经为移动设置了@media查询,但它不起作用。我的响应式网站在手机上无法使用
但是,如果我从桌面(Chrome)打开网站,我尝试调整窗口大小,它的工作原理。
HTML
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="div1">
<p class="txt">dig</p>
<p class="test">- DIG</p>
<div class="we"></div>
</div>
<div class="div2">
<p class="txt">dig</p>
<p class="test">Magni</p>
<div class="we"></div>
</div>
<div class="div3">
<p class="txt">dig</p>
<p class="test">Grillo</p>
<div class="we"></div>
</div>
</body>
</html>
CSS
body {
margin: 0px;
}
.div1 {
height: 100%;
width: 33.3%;
background-color: darkgrey;
float:left;
}
/*.we {
height: 200px;
width: 50%;
background-color: lightcoral;
margin-left: 165px;
}*/
.div2 {
height: 100%;
width: 33.3%;
background-color: darkslategray;
float:left;
}
.div3 {
height: 100%;
width: 33.3%;
background-color: darkorange;
float:left;
}
.txt {
text-align: center;
color: black;
font-size: 100;
padding-top: 50%;
}
.test {
text-align: center;
font-size: 50;
color: antiquewhite;
}
/* - - - - - - - - - - - - - - - - - - - */
@media screen
and (max-width: 320px)
and (orientation: portrait) {
body {
margin: 0px;
}
.div1 {
height: 500px;
width: 100%;
background-color: darkgrey;
}
.div2 {
height: 500px;
width: 100%;
background-color: darkslategrey;
}
.div3 {
height: 500px;
width: 100%;
background-color: darkorange;
}
.txt {
text-align: center;
color: black;
font-size: 50;
padding-top: 25%;
}
.test {
text-align: center;
font-size: 25;
color: antiquewhite;
}
}
如果你想测试你可以去:sinh.altervista.org
我怎样才能解决这个问题?什么是每个设备的真正媒体查询?在网上我发现了很多不同的@media查询。