Blueprint CSS 框架或任何网格系统:修复有边框的 div

发布于 2024-09-15 03:36:37 字数 687 浏览 10 评论 0原文

我在尝试布局网站时遇到了一些问题。我正在使用 蓝图框架,当我将边框应用于我的 div 时,就会发生这种情况。因为它们的宽度是由 span-XX (或 grid-xx ,正如我在 960gs),当我将边框应用于任何 div 元素时,它就会脱离网格,如这些图像所示 out 点击放大 替代文本 点击缩放

我知道解决这个问题的唯一方法是更改​​元素的宽度,但随后框架的网格目的就结束了,因为我将不再拥有 span-XX 类。还有其他方法可以修复吗?

I've got some problems while trying to lay out my site. I'm using Blueprint Framework and it happens when I apply borders to my div. Since their width are controlled by span-XX (or grid-xx as I noticed in 960gs), the moment I apply borders to any div element I have it goes out of the grid as seen in these images out Click to zoom
alt text
Click to zoom

The only way I know to fix it is to change element's width, but then the framework's grid purpose finishes 'cause I won't have the span-XX classes anymore. Is there any other way to fix it?

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

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

发布评论

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

评论(2

稀香 2024-09-22 03:36:40

如果我理解正确的话,您有一个 span-24 或类似的东西,并且想要为其添加边框,对吗?我首选的方法是

<div class="span-24">
    <div class="box">here</div>
</div> 

将边框添加到上面代码片段的 box 类中。

If I understand it right, you have a span-24 or something similar and want to add a border to it, right? My preferred way of doing it is

<div class="span-24">
    <div class="box">here</div>
</div> 

and add the border to the box class for above snippet.

绮烟 2024-09-22 03:36:40

如果您不想嵌套 div,您可以为边框列创建一些附加类。我使用 1px 边框,所以我创建了这样的类:

.with-border-first {
  border: 1px solid red;
  margin-right: 8px;
}

.with-border {
  border: 1px solid red;
  margin-left: -1px; 
  margin-right: 9px;
}

.with-border-last {
  border: 1px solid red;
  margin-left: -2px;
}

如果你想要跨越所有列的 div 周围的边框(例如蓝图中的 24),则应该再有一个。

然后我将这些类与跨度一起使用,例如:

<div class="span-8 with-border-first">
...
</div>

<div class="span-8 with-border">
...
</div>

<div class="span-8 last with-border-last">
...
</div>

If you don't want to nest divs, you can create a few additional classes for bordered columns. I'm using 1px borders, so I created classes like:

.with-border-first {
  border: 1px solid red;
  margin-right: 8px;
}

.with-border {
  border: 1px solid red;
  margin-left: -1px; 
  margin-right: 9px;
}

.with-border-last {
  border: 1px solid red;
  margin-left: -2px;
}

There should be one more if you want borders around divs spanning all columns (eg. 24 in blueprint).

I then use those classes together with the spans, for example:

<div class="span-8 with-border-first">
...
</div>

<div class="span-8 with-border">
...
</div>

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