【发布时间】:2017-03-16 10:07:21
【问题描述】:
如何在 css 中使用 @media 来获得特定的分辨率?所以我想让我的侧边栏更改取决于用户分辨率,所以我使用@media。
这是示例代码:
@media (max-width: 1920px) and (min-width: 1080px){ /*for 1920 x 1080*/
.logo1{
margin-top: 70%;
}
.socmed a:nth-child(1), .socmed a:nth-child(2){
margin-top: 100%;
}
}
@media (max-width: 1680px) and (min-width: 1050px){ /*for 1680 x 1050*/
.logo1{
margin-top: 70%;
}
.socmed a:nth-child(1), .socmed a:nth-child(2){
margin-top: 90%;
}
}
@media (max-width: 1600px) and (min-width: 900px){ /*for 1600 x 900*/
.logo1{
margin-top: 50%;
}
.socmed a:nth-child(1), .socmed a:nth-child(2){
margin-top: 40%;
}
}
@media (max-width: 1440px) and (min-width: 900px){ /*for 1440 x 900*/
.logo1{
margin-top: 40%;
}
.socmed a:nth-child(1), .socmed a:nth-child(2){
margin-top: 50%;
}
}
@media (max-width: 1400px) and (min-width: 1050px){ /*for 1400 x 1050*/
.logo1{
margin-top: 70%;
}
.socmed a:nth-child(1), .socmed a:nth-child(2){
margin-top: 90%;
}
}
@media (max-width: 1366px) and (min-width:768px){ /*for 1366 x 768 until 1024 x 768*/
.socmed a:nth-child(1), .socmed a:nth-child(2){
margin-top: 20%;
}
}
在那些代码中,我对使用分辨率进行了注释,它运行良好,直到我从 1366x768 打开我的网站并在下面打开,它被@media (max-width: 1400px) and (min-width: 1050px) 覆盖。我如何防止它出现这个问题?谢谢
【问题讨论】:
-
你用错了宽度和高度。
-
天哪,所以我应该使用最小宽度和最小高度? @Roberrrt
标签: html css responsive-design media-queries screen-resolution