html - 尝试在两个浮动 div 下方添加一条水平线
问题描述
我试过查看堆栈溢出但找不到答案。无论如何,我正在尝试在两个浮动 div 下方添加一条水平线。水平线仅低于第一条,但不低于第二条。如果可行的话,我宁愿它们不是浮动的。他们只需要彼此保持一致。这是html
<h1 id="quoteSumTitle">Quote Summary</h1>
<h4 id="quotePriceText">Total cost "the quote price WIP"</h4>
<h5 id="CustomerTitle">Customer</h5>
<hr />
<div id="CustomerInfoInline" style="float:left">
<section>
<h6>Name: "insert"</h6>
<h6>Address: "insert"</h6>
<h6>City, State, Zip: "insert"</h6>
<h6>SSN: "insert"</h6>
<h6>DOB: "insert"</h6>
<h6>Email: "insert"</h6>
<h6>DOB: "insert"</h6>
<h6>Prev. Carrier: "insert"</h6>
</section>
<hr id="hrBelowCustomer" />
</div>
<div id="CustomerDiscountsInline" style="float:right">
<section>
<h6 id="customerBold">Customer Discounts</h6>
<h4 id="DiscountsID">discounts will be applied here</h4>
</section>
<hr />
</div>
和相应的CSS
#quoteSumTitle{
text-align:center;
margin-bottom: 60px
}
#quotePriceText{
text-align:center;
margin-bottom:40px
}
#CustomerTitle{
color:lightslategray
}
#CustomerDiscountsInline{
vertical-align:top;
}
hr {
clear: left;
clear:right
}
#hrBelowCustomer{
top:500px;
}
解决方案
您可以删除floats
并改用,用一个 parentflex
包装两者。你可以这样做:divs
div
#quoteSumTitle{
text-align:center;
margin-bottom: 60px
}
#quotePriceText{
text-align:center;
margin-bottom:40px
}
#CustomerTitle{
color:lightslategray
}
#CustomerDiscountsInline{
vertical-align:top;
}
hr {
clear: left;
clear:right
}
#hrBelowCustomer{
top:500px;
}
.info{
display:flex;
flex-direction:row;
justify-content: space-between
}
<h1 id="quoteSumTitle">Quote Summary</h1>
<h4 id="quotePriceText">Total cost "the quote price WIP"</h4>
<h5 id="CustomerTitle">Customer</h5>
<hr />
<div class="info">
<div id="CustomerInfoInline">
<section>
<h6>Name: "insert"</h6>
<h6>Address: "insert"</h6>
<h6>City, State, Zip: "insert"</h6>
<h6>SSN: "insert"</h6>
<h6>DOB: "insert"</h6>
<h6>Email: "insert"</h6>
<h6>DOB: "insert"</h6>
<h6>Prev. Carrier: "insert"</h6>
</section>
</div>
<div id="CustomerDiscountsInline">
<section>
<h6 id="customerBold">Customer Discounts</h6>
<h4 id="DiscountsID">discounts will be applied here</h4>
</section>
</div>
</div>
<hr />
推荐阅读
- android - 使用 TalkBack 的嵌套 Recyclerview 似乎跳过了元素并且没有按显示的顺序阅读内容
- typescript - 在 TypeScript 中使用不同泛型列表而不丢失原始类型信息
- chromium - libcef.dll 在我的机器上安装了 7 次
- c++ - 多线程仿真比单线程慢几个数量级
- coldfusion - 避免与嵌套的 cfoutput 和 cfloop 重复
- javascript - React - REST:javascript fetch 帖子空正文
- gitlab - gitlab:网页只返回 502(哎呀,GitLab 响应时间太长了。)
- python - 在 Jupyter 单元格占位符中显示变量值,可以从另一个函数更新
- html - 点击图标后汉堡菜单不显示。我能做些什么?
- .net - Windows 身份验证网站、Chrome、IIS 和 Sharepoint 身份验证