html - 需要所有的 div 出现在同一行

标签 html css

我对 div 项 section1、section2、section3 有疑问,因为我需要将它们设置成一行。 Section3 似乎低于其他两个。你知道为什么会这样吗?我需要他们都在同一行。

issue

div.bodySection
{
padding:5px;
background-color:lime; 
margin-left:10px;
display:inline-block;
}

<div id="section">

<div id="section1" class="bodySection">
<h1><London></h1>
<p>London is the capital city of England.</p>
</div>

<div id="section2" class="bodySection">
<h2><London></h2>
<p1>London is the capital city of England.</p>
</div>

<div id="section3" class="bodySection">
<h3><London></h3>
<p1>London is the capital city of England.</p>
</div>

</div>

最佳答案

看起来你可以使用 CSS flexboxes:https://jsfiddle.net/p22u9h1L/

为您的 section div 添加另一个 CSS block 可以解决您的对齐问题:

div#section
{
display: -webkit-flex;
display: flex;
}

关于html - 需要所有的 div 出现在同一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35978514/

相关文章:

javascript - 如果满足条件,则在另一个转换期间添加并发转换

php - 带有 <ul> 标签的 Yii CListView

javascript - 如何获取html页面的源代码

css - 子div的高度溢出父容器

javascript - 在浅色和深色主题之间切换

python - BeautifulSoup无需页面结构即可获取数据

CSS div 溢出。 (调整浏览器大小时)

css - 如何将 2 个动画添加到 1 个关键帧

javascript - 如何更新移动对象的 Bootstrap (工具提示)?

html - Internet Explorer 11 z 索引 html/css 错误