这是我的代码:
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<div style="border-bottom:1px solid black">
<div style="width=50%;float:left">A paragraph with no margins specified
<br>
<br>A paragraph with a 2cm left margin.</div>
<div style="width=50%;margin-left=51%">A paragraph with no margins specified.</div>
</div>
</body>
</html>
我想在外部div的底部显示边框,但边框始终显示在第一个内部div之后。边框的代码是错误的吗?
答案 0 :(得分:0)
从顶部div中删除float: left
。它的罪魁祸首
答案 1 :(得分:0)
如果您需要保留浮点数,则可以将父div的overflow
属性更改为auto
。
<div style="border-bottom:1px solid black; overflow:auto;">
<div style="width=50%;float:left">A paragraph with no margins specified
<br>
<br>A paragraph with a 2cm left margin.</div>
<div style="width=50%;margin-left=51%">A paragraph with no margins specified.</div>
</div>
&#13;