javascript - 如何删除动态内容底部的空间?

标签 javascript jquery css html

我正在设计一个页面,其中 div 的底部应该触及没有底边距或填充的页面末尾,所以我将主 div 的高度设置为

 $(function() {
     $('.divMain').css({'height': (($(window).height())) + 'px'});

     $(window).resize(function() {
         $('.divMain').css({'height': (($(window).height())) + 'px'});
     });
 });

我的 HTML 是:

<div class="divMain">
    <table id="eduGrid"></table>
</div>

其中 “eduGrid” 是动态生成的(Bootstrap)。

最初它工作正常,但我在该 div 中有一些内容可以在用户端添加(添加新教育等),以便内容移动到主 div 之外并且看起来有线。

最佳答案

检查全屏结果 - http://fiddle.jshell.net/DRRsn/1/show/light/

检查此 fiddle 代码 - http://jsfiddle.net/DRRsn/1/

CSS

html,body{width:100%;height:100%; overflow:hidden; margin:0;padding:0;}
div{background:blue;}
table{background:pink;height:100%;;width:50%}

HTML

<div class="divMain">
<table id="eduGrid"></table>
</div>

JS

$(function() {
    $('.divMain').css({'height': (($(window).height())) + 'px'});
    $(window).resize(function() {
        $('.divMain').css({'height': (($(window).height())) + 'px'});
    });
});

希望这就是您要找的。

关于javascript - 如何删除动态内容底部的空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16643566/

相关文章:

javascript - 不同的 ng-switch 动画

LI 上的 jQuery 单击功能在 IE 中不起作用

css - 通过关键帧的多个背景图像位置的动画在 Chrome 和 Safari 中有效,但在 Firefox 中无效

html - 在 twitter bootstrap 页脚中居中三个 div

php - 需要帮助 - 单击图像以设置字段的状态

javascript - 如何从PHP中的复选框中的文本框获取值

javascript - Protractor、Jasmine 和在第一次失败时停止测试

javascript - jQuery 范围 slider grep 返回具有最小值和最大值的项目

JQuery UI 停止激活两次

javascript - 链接环绕在 Jquery 中的图像点击事件