Html 我如何使两个div相邻浮动,但不让下面的内容跟随?
我有以下设置,带有HTML:Html 我如何使两个div相邻浮动,但不让下面的内容跟随?,html,css,css-float,Html,Css,Css Float,我有以下设置,带有HTML: <h4 class="wrap-title">Name</h4> <button class="btn btn-primary btn-xs title-button" ng-click="uploadNewImage()"><span class="glyphicon glyphicon-upload"></span> Upload</button>
<h4 class="wrap-title">Name</h4>
<button class="btn btn-primary btn-xs title-button" ng-click="uploadNewImage()"><span class="glyphicon glyphicon-upload"></span> Upload</button>
<p>{{venue.name}}</p>
我该如何让面霜隐藏在“名字”下面呢?提前谢谢!出于某种原因,我一辈子都想不出该怎么做。您需要清除浮动:
p {
clear:left:
}
将浮动包在div中并使用clearfix可能会更干净一些
<div class="clearfix">
<h4 class="wrap-title">Name</h4>
<button class="btn btn-primary btn-xs title-button" ng-click="uploadNewImage()">
<span class="glyphicon glyphicon-upload"></span> Upload
</button>
</div>
<p>{{venue.name}}</p>
以下是html5样板中给出的解释
Clearfix:包含用于现代浏览器的浮动
contenteditable
属性包含在文档的任何其他位置时,空格内容是避免Opera错误的一种方法。
否则,它会在元素的顶部和底部显示空间
接收clearfix
类的表格
而不是块
:在
之前,包含子元素的顶部边距谢谢我可以问一下内容/显示属性是如何做到这一点的吗?我已经在答案中添加了html5样板中的解释
<div class="clearfix">
<h4 class="wrap-title">Name</h4>
<button class="btn btn-primary btn-xs title-button" ng-click="uploadNewImage()">
<span class="glyphicon glyphicon-upload"></span> Upload
</button>
</div>
<p>{{venue.name}}</p>
.clearfix:before, .clearfix:after { content: " "; display: table; }
.clearfix:after { clear: both; }