窗口大小调整不起作用
Window resize is not working
我为Q& a测验做了一个标记。
当我尝试调整窗口大小时,我得到了无效的高度和宽度值。例如:在移动视图上,我得到了以下值height: 9428992px; width: 880px;
!!!!?
$.getDocHeight = function(){
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
);
};
$.getDocWidth = function(){
var D = document;
return Math.max(
Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
Math.max(D.body.clientWidth, D.documentElement.clientWidth)
);
};
所有的html, css和jQuery代码都在这里节省空间。
我不确定它为什么会这样。是我的CSS还是HTML结构?!!
我还发现<section class="bottom row">....</section
填充了底部的部分,直到窗口的末端,但它的大小超过了可见窗口(条款和条件部分未显示)。
我不知道如果更好的html结构会解决这个JS问题!
我很感激你的帮助!谢谢。
这就是我想要完成的,也许我的结构或风格不正确。
用户希望打开页面并看到第一部分填满屏幕。红色部分填充顶部,然后蓝色填充"窗口/页面"的其余部分。因此,用户应该看到所有上下文从顶部图像开始,并以右下角的"条款和条件"结束。
当用户点击'START QUIZ'时,<div class="section">...
应该动画到顶部,<div id="section-1">..
将取代它。
之后,当用户点击'TRUE'或'FALSE'窗口应该动画到右边的部分,以查看<class class="answerswer">
部分的更多细节。它有一个"下一步"按钮。当用户点击它的窗口应该动画显示一个新的部分'....'。
以此类推。这就是整个想法。希望这解释了每个部分的流程。
谢谢。
首先去掉不必要的分号
function sizeUpdate(){
widnowHeight = $.getDocHeight();
widnowWidth = $.getDocWidth();
$('#value').html(widnowHeight);
$(".section").css("height", widnowHeight);
$(".section").css("width", widnowWidth);
if (selected_section == 2){
$("#section-1").css("margin-top", widnowHeight*-1);
$("#section-1").css("margin-left", widnowWidth*-1);
};//Semicolon not required
if (selected_section == 3) {
$("#section-1").css("margin-top", widnowHeight*-1);
$("#section-2").css("margin-top", widnowHeight*-1);
$("#section-1").css("margin-left", widnowWidth*-1);
$("#section-2").css("margin-left", widnowWidth*-1);
};//Semicolon not required
if (selected_section == 4) {
$("#section-1").css("margin-top", widnowHeight*-1);
$("#section-2").css("margin-top", widnowHeight*-1);
$("#section-3").css("margin-top", widnowHeight*-1);
$("#section-1").css("margin-left", widnowWidth*-1);
$("#section-2").css("margin-left", widnowWidth*-1);
$("#section-3").css("margin-left", widnowWidth*-1);
};//Semicolon not required
};//Semicolon not required
这里是代码检查一下是否正常http://jsbin.com/yesenutoki/1/edit?html,css,js
<p>Try resizing this browser window to trigger the "resize" event handler.</p>
<p id="demo"></p>
<script>
window.addEventListener("resize", function(){
document.getElementById("demo").innerHTML = window.innerWidth+" "+window.innerHeight;;
});
</script>
当你调整窗口大小时,它会给你当前的屏幕宽度和高度。试试
- 我需要一种自动调整iframe大小的方法,无论我查到什么,它都不起作用
- jQuery 可调整大小() 不起作用(带有示例)
- jquery在调整大小时响应不起作用
- 可拖动或可调整大小的文本区域不起作用
- jQuery-ui 可调整大小,在 Marionette.ItemViem 上不起作用
- jquery调整大小函数没有'不起作用
- 可调整大小的包含对我不起作用
- 旋转图像w/jQuery..但是调整大小不起作用
- JQuery 可调整大小的取消不起作用
- TinyMCE 自动调整大小插件不起作用
- 如何在客户端上调整图像大小,不起作用
- 窗口.调整大小到不起作用
- iframe 自动调整高度大小不起作用
- Jquery UI 在新元素上可调整大小不起作用
- iframe调整器不起作用/源页面甚至无法滚动
- 完整日历:在开始日期启用时间时,调整大小不起作用
- 将图像大小调整为使用 Javascript 调整窗口大小 - 在 Chrome 中不起作用
- JavaScript 不起作用,直到我调整窗口大小然后调整大小
- 调整谷歌地图的大小不起作用,需要很长时间
- 为什么jquery调整大小不起作用