j查询比较高度未在降低高度时运行
jQuery compare height not running on reduction of height
我有以下jQuery检查左右列的高度。如果警报列表(左)的高度增加,则侧边栏行的高度也会增加以匹配。但是,一旦增加,并且警报列表减少(通过选择不同的区域或更少的警报数量),包含所有内容的侧边栏和整个行的高度不会降低,从而在下面留下巨大的空间。
要复制问题,请执行以下操作:
选择圣海伦斯区域。
选择 100 个警报
现在选择威勒尔地区。
包含高度不会降低。
http://178.62.45.247/areas.php
*请注意,这必须适用于IE7及更高版本 *
function areasRowHeight() {
$height1 = $('.nopr').height();
$height2 = $('.nopl').height();
if($height1 > $height2) {
$('.areasrow').height($height1);
}
else {
$('.areasrow').height($height2);
}
}
$(document).ready(function(){
$( window ).resize(function() {
maxHeight('.nopr', '.nopl');
});
$( window).scroll(function(){
maxHeight('.nopr', '.nopl');
});
$( window ).on( "orientationchange", function( event ) {
maxHeight('.nopr', '.nopl');
});
$('.burgermenu').on('click', function(event){
$(this).css('display', 'none');
$('.cancel').css('display', 'inline-block');
$('.smnav').css('display', 'block');
// $('.burgermenu').attr('class', 'burgermenu-open')
event.preventDefault();
});
$('.cancel').on('click', function(event){
$(this).css('display', 'none');
$('.burgermenu').css('display', 'inline-block');
$('.smnav').css('display', 'none');
// $('.burgermenu').attr('class', 'burgermenu-open')
event.preventDefault();
});
$('.show5').on('click', function(event){
hide('.latestalerts ul', 5);
maxHeight('.nopr', '.nopl');
$('.areasrow').height('auto');
event.preventDefault();
});
$('.show10').on('click', function(event){
hide('.latestalerts ul', 10);
maxHeight('.nopr', '.nopl');
$('.areasrow').height('auto');
event.preventDefault();
});
$('.show100').on('click', function(event){
hide('.latestalerts ul', 50);
maxHeight('.nopr', '.nopl');
$('.areasrow').height('auto');
event.preventDefault();
});
$('.showall').on('click', function(event){
resetHide();
maxHeight('.nopr', '.nopl');
$('.areasrow').height('auto');
event.preventDefault();
});
var trigger = $('.button li a'),
container = $('.latestalerts');
trigger.on('click', function(event){
windowAnchor();
event.preventDefault();
var $this = $(this),
target = $this.data('target');
$('#content').load('controllers/areaload/' + target + '.php');
areasRowHeight();
});
maxHeight('.nopr', '.nopl');
});
我没有IE7,但如果我正确理解,您应该从style.css
中删除
.areasrow .nopr {
height: 100% !important;
}
.areasrow .nopl {
height: 100% !important;
}
.areasrow .nopr .inner-content {
height: 100% !important;
}
.areasrow .nopl .sidebarbg {
height: 100%;
}
然后更改main.js
$('#content').load('controllers/areaload/' + target + '.php');
areasRowHeight();
自
$('#content').load('controllers/areaload/' + target + '.php', function(){
maxHeight('.nopr', '.nopl');
});
有点脏,但有了这个文档结构,这就是我能建议的。
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 如何使用phaser使html5游戏在移动设备浏览器上运行
- 使用压缩的JavaScript文件(不是运行时压缩)
- ExtJS——在展开/折叠时调整面板高度
- Javascript运行php文件,然后下载文件
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- 分析高度属性时出现意外值{{specs.height}}.index.html
- 我已经创建了一个jquery转盘,并使用if条件来运行和停止转盘
- Angularjs代码未在匿名函数中运行
- 单击页面上的链接后高度发生变化
- jquery设置为使用参数运行
- 如何根据时间运行不同的脚本
- Meteor方法在客户端返回null,在客户端运行的相同方法返回正确的值
- 将文本框链接到由按钮运行的javascript公式
- 导致javascript停止运行的最大高度
- 当脚本运行时,它每秒将 4px 添加到我的容器的高度,只发生在 Firefox 中
- 如何防止在 Safari 中使用 javascript 设置高度后在页面加载时运行过渡
- 通过在运行时使用 CSS 设置其高度/宽度来拉伸 img 会产生奇怪的渐变
- j查询比较高度未在降低高度时运行
- jQuery抓取高度和运行函数仅用于此项