CSS自动宽度不带边距的布局:auto [英] CSS auto-width Layout without margin:auto
问题描述
这可能与css(我可以用javascript管理它):
Is this possible with css (I can probably manage it with javascript):
它基本上是一个 margin:auto
效果,但我想要一个不同的背景为每个边距,所以我正在寻找divs与自动宽度在(固定宽度)中心div的两侧,如果这是有道理的。 Probs更好地可视化:
Its basically a margin: auto
effect, but i want a different background for each margin, so i'm looking for divs with auto-widths on either side of the (fixed-width) center div if that makes sense. Probs better visualized:
推荐答案
我没有使用你的宽度值,因为jsFiddle需要调整大小来看它是如何工作的。
I didn't use your width value as jsFiddle would need resizing to see how it works.
这本质上告诉divs作为表格单元格,包含div,它充当表。如果没有指定中间div的宽度,则每个列的宽度将为33%。
This essentially tells the divs to act as table-cells, so they will fill the containing div, which acts as the table. If you didn't specify the width of the middle div, each column would be 33% wide.
这篇关于CSS自动宽度不带边距的布局:auto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!