html - 如何使我的两个并排 div 具有相同的高度?

标签 html css

My code @ JSFiddle

code that is needed
for linking JSFiddle
links
I don't understand why I need
this.

An image of the two divs, their the gray boxes.

如何使这两个 div 具有相同的高度?我不想做 padding-bottom: px;和底部边距:-px;这看起来真的像是作弊而且只是被操纵了。

最佳答案

您可以使用 display:tabledisplay:table-cell:

#who-is {
    width: auto;
    display: table;
}

#left {
    width: 40%;
    padding: 5%;
    text-align: center;
    background: #CCC;
    display: table-cell;
}

#left h1 {
    font-size: 72px;
    text-transform: uppercase;
}

#right {
    width: 40%;
    padding: 5%;
    background: #eee;
    display: table-cell;
}

#right p {
    font-size: 16px;
}

fiddle

关于html - 如何使我的两个并排 div 具有相同的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24851073/

相关文章:

javascript - 使用javascript在图像上显示文本

javascript - 缩放后的图像在右下角显示不正确并且使用了更大的比例

html - 3 列设置 CSS 问题

javascript - 如何根据用户请求生成多个输入?

javascript - 如何才能有一个仅在移动设备上显示的可折叠按钮?

html - 伪元素的中心元素

css - 不需要的间距和旁边没有正确定位

jquery - 购物车/ list 但未付款

html - 单个类的两个悬停状态

css - 悬停行动缓慢?