如何自动扩展div / span,就像一张桌子?

时间:2012-03-27 10:07:22

标签: width html

所以,这就是我想要的:

<span>Field 1</span><span>Field 2</span><span>Field 3</span><br />
<span>Content A1</span><span>Content B1</span><span>Content C1</span><br />
<span>Content A2</span><span>Content B2</span><span>Content C2</span><br />
<span>Content A3</span><span>Content B3</span><span>Content C3</span><br />

现在我希望Field1的宽度为最大常数A1 /常数A2 /常数A3。换句话说,每列自动扩展到内容的最大宽度。就像在表格中一样。它可行吗?

1 个答案:

答案 0 :(得分:3)

你可以使用这个css: span{ display: table-cell; }

http://www.w3schools.com/cssref/pr_class_display.asp