【发布时间】:2014-12-26 15:20:13
【问题描述】:
大家,我尝试制作一个响应式网站,所以我添加了媒体查询 就像这样:
@media (min-width: 838px) {
bigscreen code
}
@media (max-width: 837px) {
littlescreen code
}
但是当我用 JS 做一些事情时,比如
if($(document).width()<837+1){
code
}
我制作了一个 console.log($(document).width())。当 $(document).width() = 820 时发生 css littlescreen 代码,但我不知道为什么。 如果有人知道,谢谢你
编辑: $(window).width() = $(document).width() = $('body').innerWidth() = $(window).innerWidth() = $(document).innerWidth()
【问题讨论】:
-
那么
820不小于837?? -
@Pointy 是的,但我的媒体查询仅在 js 说宽度为 820 时才起作用
标签: html css responsive-design width media-queries