【发布时间】:2013-09-13 10:53:03
【问题描述】:
我想将屏幕宽度作为一个简单 if 语句的变量。基本上如果屏幕> 768,它将显示正常的网站。如果它
【问题讨论】:
我想将屏幕宽度作为一个简单 if 语句的变量。基本上如果屏幕> 768,它将显示正常的网站。如果它
【问题讨论】:
【讨论】:
您需要 CSS3 媒体查询
http://www.w3.org/TR/css3-mediaqueries/
http://webdesignerwall.com/tutorials/css3-media-queries
/* Any CSS for bigger screens / default CSS goes outside the brackets */
div {
/*here*/
}
p {
/*or here*/
}
@media screen and (max-width: 768px) {
/*css specific to small screens under 768px width here*/
div {
/*here*/
}
p {
/*or here*/
}
}
【讨论】:
您可以使用 CSS 媒体查询:
@media all and (max-width: 768px) {
body {
background: #ccc;
}
}
【讨论】: