相关疑难解决方法(0)

jQuery height()在可见div上返回0 - 为什么?

我有一个容器(thetext1),设置高度为360px."thetext1"包含两个div--一个在左边,一个向右浮动 - 两个内容都是通过ajax调用传递的.

有时候这些div中的一个或另一个中的内容超过360px,因此我想相应地增加text1的高度.

我的测试代码

newhgt = $('#thetext1').find('div.rhs').css("background", "pink").height();
Run Code Online (Sandbox Code Playgroud)

返回0 - (我的选择器是正确的,因为目标div是完全粉红色的!).

为什么是这样?我知道 - 从本网站以前帖子的答案 - 解决方案是添加溢出:隐藏thetext1,但我想理解为什么我试图获得rhs和lhs div的高度失败.

css jquery

40
推荐指数
3
解决办法
4万
查看次数

修复Bootstrap表的第一列

我在这篇文章中关注了@ koala_dev的代码,试图锁定我的表水平滚动的第一列.不幸的是,代码对我的表没有影响.我想知道是否有人可以给我一些关于我做错了什么的指示,因为我是编程新手.

这是我的桌子:http: //jsfiddle.net/mademoiselletse/bypbqboe/59/

这是我在JS中插入的代码(第121-133行):

$(function() {
    var $tableClass = $('.table');
    // Make a clone of our table
    var $fixedColumn = $tableClass.clone().insertBefore($tableClass).addClass('fixed-column');

    // Remove everything except for first column
    $fixedColumn.find('th:not(:first-child),td:not(:first-child)').remove();

    // Match the height of the rows to that of the original table's
    $fixedColumn.find('tr').each(function(i, elem) {
      $(this).height($tableClass.find('tr:eq(' + i + ')').height());
    });
});
Run Code Online (Sandbox Code Playgroud)

这是我插入的CSS属性(第36-47行):

.table-responsive > .fixed-column {
   position: absolute;
   display: inline-block;
   width: auto;
   border-right: 1px solid #ddd;
}

@media(min-width:768px) {
    .table-responsive>.fixed-column {
        display: none;
    } …
Run Code Online (Sandbox Code Playgroud)

javascript css bootstrap-table

18
推荐指数
2
解决办法
5万
查看次数

标签 统计

css ×2

bootstrap-table ×1

javascript ×1

jquery ×1