gpt4 book ai didi

jquery - Chrome 中媒体查询最大宽度以错误的宽度启动

转载 作者:行者123 更新时间:2023-12-03 23:05:55 26 4
gpt4 key购买 nike

编辑:更多研究表明这实际上与 jQuery returns wrong width and height in Chrome 18.0.1025.168 有关

我已经在当前的 WordPress 主题项目上设置了一些媒体查询和一些 javascript。一般来说,它们工作得很好,但是(!)媒体查询:

@media only screen and (max-width: 980px)

已在 1075 像素处生效。

$(document).width()
1075
$("body").width()
1019.4444427490234

这发生在 Chrome 中,但在 Safari 中它的行为就像它应该的那样。我没有检查过任何其他浏览器。

你能以某种方式通过javacript改变元素的宽度来破坏查询正确的“launch-widths”吗?

CSS:

@media only screen and (max-width: 1060px){
.excerpt{
width: 500px;
float: left;
font-size: 13px;
}
}
@media only screen and (max-width: 980px){
.hentry{
height: auto;
}
.thumbnail,.excerpt{
float: none;
max-height: none;
}
p{
font-size: 15px;
}
#site-description{
display: none;
}
}

在此之前最新添加的 JavaScript:

if($(window).width()<1065 || $(document).width()<1065){
if($(document).width()>980){
$(".excerpt").width($(".hentry").width()-515);
} else{
$(".excerpt").css("width","");
}
}

最佳答案

你确定它与 jQuery 有关吗?

我遇到了同样的问题(媒体查询以错误的宽度触发),原因是我在 Chrome 中的缩放级别不是 100%。我知道,我傻了。

只需按 cmd+0 或 ctr+0 即可默认为 100%。

关于jquery - Chrome 中媒体查询最大宽度以错误的宽度启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11410038/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com