使两个平行的< div>`colums具有相同的高度

编程入门 行业动态 更新时间:2024-10-23 01:38:31
本文介绍了使两个平行的< div>`colums具有相同的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

假设我有两个列,都由< div> 块表示。

Suppose I have two columns, both represented by a <div> block. Both columns may grow larger than the other, so I want to force the smaller one to grow as big as the other.

我的问题的例子: jsfiddle/TvnSJ/

如您所见,第二列较小。

As you can see, the second column is smaller.

我设法使用表来解决这个问题,但是我无法在它们之间添加边距。边距很重要,所以我想知道另一个解决方案。

I managed to solve this using tables, but I was unable to add margin between them. The margin is important, so I would like to know another solution.

推荐答案

.box { width:100px; display:box; /* Firefox */ display:-moz-box; -moz-box-orient:horizontal; /* Safari, Opera, and Chrome */ display:-webkit-box; -webkit-box-orient:horizontal; /* W3C */ display:box; box-orient:horizontal; } .box .column1 { -moz-box-flex:1.0; /* Firefox */ -webkit-box-flex:1.0; /* Safari and Chrome */ -ms-flex:1.0; /* Internet Explorer 10 */ box-flex:1.0; background: yellow; } .box .column2 { -moz-box-flex:1.0; /* Firefox */ -webkit-box-flex:1.0; /* Safari and Chrome */ -ms-flex:1.0; /* Internet Explorer 10 */ box-flex:1.0; background: green; }

和HTML

<div class="box"> <div class="column1"> a<br>b </div> <div class="column2"> a </div> </div>

我使用这里的示例 www.w3schools

小提琴 jsfiddle/w5ELr/

更多推荐

使两个平行的&lt; div&gt;`colums具有相同的高度

本文发布于:2023-10-08 01:45:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471152.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:高度   两个   amp   div   lt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!