首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >三分表-排列为表

三分表-排列为表
EN

Stack Overflow用户
提问于 2013-09-17 22:13:27
回答 3查看 205关注 0票数 0

我有三块钱:

代码语言:javascript
复制
<div>
    <div class="one"></div>
    <div class="two"></div>
    <div class="three"></div>
</div>

.one {
    width: 100px;
    height: 200px;
    background-color: red;
}

.two {
    width: 100px;
    height: 100px;
    background-color: green;
    float: left;
}

.three {
    width: 100px;
    height: 100px;
    background-color: blue;
    float: left;
}

但这不太好。我希望收到:

代码语言:javascript
复制
<table>
    <tr><td rowspan="2" class="one"></td><td class="two"></td></tr>
    <tr><td class="three"></td></tr>
</table>

活着

我怎样才能用DIV制作它,就像用桌子一样?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-09-17 22:26:59

要做到这一点,有几种方法。

一种选择是使用display:table-cell和相关的样式来使它精确地表现为一个表。

另一种方法是按照您的要求使用float,但是定义容器的width,并使用clear来根据需要对它们进行定位。

下面是后一种选择的小提琴:http://jsfiddle.net/adnrw/7datp/4/paddingmargin一起展示,与在cellspacingcellpadding中构建的table相匹配

票数 0
EN

Stack Overflow用户

发布于 2013-09-17 22:29:18

的简单答案是使用CSS将其显示为一个表.

您可以使用以下样式来实现不使用HTML的表布局。

代码语言:javascript
复制
display: table;
display: table-cell;
display: table-column;
display: table-colgroup;
display: table-header-group;
display: table-row-group;
display: table-footer-group;
display: table-row;
display: table-caption;
票数 1
EN

Stack Overflow用户

发布于 2013-09-17 22:27:10

试一试,就像:

代码语言:javascript
复制
.one,.two,.three{
  width:100px; float:left;
}
.one{
   height:200px; background-color:red;
 }
.two{
   height:100px; background-color:green;
}
.three{
  height:100px; background-color:blue; clear:left;
}

基本上,就是clear:left; on .three。为了在容器上保留所有3个div的高度,您可能需要在容器上添加一个divclear:left;,而不需要浮动。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18860767

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档