YUI CSS 基本网格模式:使用 jQuery 获取右侧网格 (yui-ge) 的宽度和边距

发布于 2024-08-30 05:04:42 字数 724 浏览 3 评论 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。有人知道该怎么做吗?

I have this Basic Grid Pattern on my website:

<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>

This setup gives me this:

alt text http://horgenweb.org/temp/yui_jquery_width.jpg

I'm trying to get the width of the right div + the left margin width jQuery.

$('#right_cont').width() 

Gives me the box-width only 325px. Anyone know how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

口干舌燥 2024-09-06 05:04:43

回答我自己的问题:

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

有更好的方法吗? o_O

To answer my own question:

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

Is there a better way? o_O

花之痕靓丽 2024-09-06 05:04:43

使用outerWidth(),并传递一个真值作为参数,以便它包含边距。

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

文档页面: http://api.jquery.com/outerWidth/

Use outerWidth(), and pass a truthy value as an argument so it includes the margin.

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

Docs page: http://api.jquery.com/outerWidth/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文