我在页面加载功能期间遇到时间问题。我需要获得图像宽度的问题
(1)已加载
(2)通过CSS调整的100%宽度
图像宽度设置为100%并在我的AJAX POST返回后调整大约300ms但我不想在加载时使用超时可能会有所不同。
xPos = Math.round((Math.random() * 100) * 10) / 10;
yPos = Math.round((Math.random() * 100) * 10) / 10;
我需要在调整到父元素的100%(基于窗口大小)之后获取图像的宽度,直到那时才运行下一个AJAX POST。无论如何我还能正确地做到这一点吗?
谢谢你的期待!
答案 0 :(得分:2)
我真的建议您使用jquery.waitForImage它为您完成所有加载图像,加载后您可以随意播放。
答案 1 :(得分:0)
if($("#page-view .page img").first().width() == $("#page-view .page img").first().parent().width())
当Image与父宽度
匹配时,您可以创建一个使用上述逻辑进行检查的函数答案 2 :(得分:0)
以下是您可以在css文件中包含的代码示例,以便在执行媒体查询之前调整您的图片:
body::before {
opacity:0.3;
background: url(/images/DNA.jpg) no-repeat center center fixed;
content: '';
z-index: -1;
width: 100%;
height: 100%;
position:absolute;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
}