【发布时间】:2018-04-18 21:41:15
【问题描述】:
页面上的元素只响应 1650px 及以上屏幕尺寸的媒体查询。结果,我无法使项目响应移动设备。台式机上的一切都很好,但平板电脑和手机屏幕没有响应。在下面发布代码。某处有错误吗?这是我的媒体查询:
@media only screen and (max-width: 380px) {
footer {
margin-top: 50px;
}
.header-image {
height: 50px;
}
#social-icons {
display: flex;
}
}
@media only screen and (max-width: 480px) {
.header-image {
height: 100px;
}
#social-icons {
display: flex;
}
.custom-logo {
margin-top: 50px;
}
}
@media only screen and (max-width: 600px) {
footer {
margin-bottom: 50px;
text-align: center;
margin: 0 auto;
}
#social-icons {
display: flex;
}
.textwidget {
display: flex;
text-align: center;
}
.widget_text {
margin-right: 60px;
}
.custom-logo {
margin: 30px;
}
}
@media only screen and (max-width: 768px) {
.header-image {
height: 100px;
}
.menu-toggle {
display: none;
}
.custom-logo {
width: 50%;
margin-top: -20px;
}
}
@media only screen and (max-width: 900px) {
.main-navigation ul li a {
font-size: 16px;
display: none;
}
.custom-logo {
width: 70%;
position: relative;
}
}
@media only screen and (max-width: 1100px) {
.main-navigation ul {
margin-top: -35px;
}
.custom-logo {
width: 50%;
margin-top: -20px;
position: relative;
}
}
@media only screen and (max-width: 1250px) {
.custom-logo {
margin-left: 30px;
}
}
@media only screen and (max-width: 1400px) {
.custom-logo {
margin-top: 50px;
width: 50%;
}
}
@media only screen and (max-width: 1500px) {
.custom-logo {
margin-left: 100px;
}
}
@media only screen and (max-width: 1650px) {
.custom-logo {
margin: 0px;
}
}
@media only screen and (max-width: 1850px) {
.custom-logo {
width: 25%;
}
}
【问题讨论】:
-
请同时发布 HTML。
-
正如在答案中发布的那样,样式表下方的查询将覆盖上面的查询。颠倒顺序,使较低的
max-width低于具有较高值的max-width。
标签: css mobile responsive-design media-queries