0

私のウェブサイトには、この基本的なグリッド パターンがあります。

<style type='text/css'>
  #doc3 { margin:auto; }
</style>

<div id="doc3">
  <div id="bd">
    <div class="yui-ge">
      <div class="yui-u first" id="main">
        Main content here
      </div>
      <div class="yui-u" id="right_cont">
        right content here
      </div>
    </div>
  </div>
</div>

この設定により、次のようになります。

代替テキスト http://horgenweb.org/temp/yui_jquery_width.jpg

右の div の幅 + 左の余白の幅 jQuery を取得しようとしています。

$('#right_cont').width() 

ボックスの幅は 325px しかありません。誰でもこれを行う方法を知っていますか?

4

2 に答える 2

0

outerWidth() を使用し、マージンを含むように真の値を引数として渡します。

$("#right_cont").outerWidth(true);

ドキュメントページ: http://api.jquery.com/outerWidth/

于 2010-05-10T17:20:53.220 に答える
0

私自身の質問に答えるには:

/* Right content width + margin */
$right_content_width = $(window).width() - $('#main').width();

より良い方法はありますか?o_O

于 2010-04-28T08:44:37.687 に答える