css - 在不使用显式高度的情况下制作相同大小的 div 边框

标签 css html size border

这把 fiddle :http://jsfiddle.net/e3Ggh/显示我的问题是什么:我需要让我的 div 的边框大小相同,即使它们的内容不同。但是,我需要在不使用明确尺寸的情况下执行此操作(div 或其父项都不应具有明确尺寸)。
HTML:

<div id="texte">
            <div>
                <p>"Lorem ipsum dolor sit amet [...]"</p>
            </div>
            <div>
                <p>At vero eos et accusamus[...]</p>
        </div>
    </div>

CSS:

        #texte{
            width:100%;
        }
        #texte>div{
            width:30%;
            display:inline-block;
            border: 1px solid black;
            vertical-align: top;
        }
        #texte>div>p{
            width:90%;
            margin: auto;
            display: block;
        }

最佳答案

您可以在主容器上使用 display: table 并在列上使用 display: table-cell 来实现您想要的效果:

#texte{
        width:100%;
        display: table;
    }
    #texte>div{
        width:30%;
        display:table-cell;
        border: 1px solid black;
        vertical-align: top;
    }
    #texte>div>p{
        width:90%;
        margin: auto;
        display: block;
    }

jsFiddle:http://jsfiddle.net/bjuice/GQmfk/1

兼容性:http://caniuse.com/css-table

关于css - 在不使用显式高度的情况下制作相同大小的 div 边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18990267/

相关文章:

javascript - 文本编辑器在 &lt;textarea&gt; 中工作,但在显示时不起作用

javascript - jQuery 插件 - 内联 CSS 或外部样式表?

html - 为什么我的图像没有粘在一起?

javascript 选项选择 IE6 与 FF2

html表格列大小

sql-server - 数据库规模巨大

css - Bootstrap 3 : Stopping hover behaviour in mobile

html - 两个div之间的水平线

html - 使用 Bootstrap 4 一个一个地折叠导航栏元素

ios - 更改方向后更改大小