1

私は、仮想的に多くの要素の間に挟まれ、サイドバーにある div を持っています。div とその下の要素の間にどれだけのスペースがあるかを計算する必要があります。次に、div の max-height を現在の高さとその下のスペースに設定して、それを超えて拡張しないようにします (したがって、ページを拡張します)。初期の最大高さは非常に小さい値であり、JS によって変更する必要があります。だから基本的に:

<thing></thing>
<div id="mydiv"></div>
<another></another>

そして、私は(jQueryの例)のようなものが必要です:

var spacebelow = space between mydiv and <another>    
var daheight = (currentheight + spacebelow); 
    $("#mydiv").attr("style", "max-height:" + daheight + "px");

とにかくこれを行うことはありますか?

4

1 に答える 1

0

私はあなたがこのようなものが欲しいと思います:-

    var divoffset=$(#divID).offset();
    var divanotheroffset=$(#divanotherID).offset();
    var spacebelow =divanotheroffset.top-divoffset.top;
    var currentheight =$(#divID).height();
    var daheight = (currentheight + spacebelow); 
    //set the max-height:-
     $("#mydiv").attr("max-height",daheight );
于 2013-04-18T06:07:00.103 に答える