CSS中的colspan [英] HTML colspan in CSS

查看:208
本文介绍了CSS中的colspan的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图构建类似以下的布局:

  + --- + --- + -  + 
| | | |
+ --- + --- + --- +
| |
+ ----------- +



如果这是一个实际的表,我可以很容易地用< td colspan =3 > ,但由于我只是创建一个类似于表格的布局,我不能使用< table> 标签。这是可能使用CSS吗?

解决方案

我必须不同意colspan是结构的唯一指示的答案,你不应该甚至试图以这种方式解决你的问题。说这话没有争议的余地,在最坏的情况下,天真,或最多,不诚实。



如果你有一个表的一部分,你选择跨越多个列出于外观的缘故,那么它是不' t结构。它的外观。而且,尽管如此,没有简单,优雅的CSS模拟。这是诚实的答案,我说,作为一个CSS粉丝。 CSS做很多事情非常,非常好。

这可能不是流行的答案,但我相信它是诚实的 >一个。事实是,结构和表现之间的区别不是一个明亮的白线,而是一个明确的模糊。我不会假定告诉你,你需要跨越列是对还是错。搜索这个问题将返回各种解决方案,包括一系列的替代方法,包括绝对定位,大小,以及类似的各种浏览器和情况特定的注意事项。阅读,并做出最好的决定,你可以根据你发现。


I'm trying to construct a layout similar to the following:

+---+---+---+
|   |   |   |
+---+---+---+
|           |
+-----------+

where the bottom is filling the space of the upper row.

If this were an actual table, I could easily accomplish this with <td colspan="3">, but as I'm simply creating a table-like layout, I cannot use <table> tags. Is this possible using CSS?

解决方案

I must respectfully disagree with the answer that colspan is exclusively indicative of structure, and the implicit notion that you shouldn't even be trying to solve your problem this way. To say this with no room for dispute is, at worst, naive, or at best, disingenuous. It is not in service to the person asking the question.

If you have a section of a table that you choose to span multiple columns for appearance's sake, then it isn't structural. It's appearance. And, despite this, there's no simple, elegant CSS analog for it. That's the honest answer, and I say that as a CSS fan. CSS does many things very, very well. Tables are not among them.

That may not be the popular answer, but I believe it to be the honest one. The truth is that the distinction between structure and presentation is not a bright white line, but a decidedly blurred one. I won't presume to tell you your need for spanning columns is right or wrong. Searches on this very issue will return a variety of solutions that include a bevy of alternatives, including absolute positioning, sizing, along with a similar variety of browser- and circumstance-specific caveats. Read, and make the best informed decision you can based on what you find.

这篇关于CSS中的colspan的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆