我认为我理解使用CSS进行clearfixing的:after
方法 - 但我似乎无法让它正常工作。出于某种原因,siblingContainer
包含浮动元素之后的buttonContainer
似乎没有清除?
HTML:
<div class="buttonContainer">
<div class="action_button">Button 1</div>
<div class="action_button">Button 2</div>
</div>
<div class="siblingContainer"></div>
CSS:
.action_button {
font-family: Arial;
font-size: 9pt;
font-weight: bold;
background-color: #f2c059;
color: white;
border-radius: 5px;
display: inline-block;
padding: 5px;
cursor: pointer;
}
.buttonContainer {
margin: 5px;
}
.buttonContainer div {
margin: 0 5px;
float: right;
}
.buttonContainer div:last-child:after {
content: "";
display: block;
clear: both;
}
.siblingContainer {
height: 500px;
background: gray;
}