css - 为什么我的内容显示在 div 之外?

标签 css html

我有一个包含内容的“气泡”,工作正常。现在,我想显示一个计数(2 行),它应该始终位于该 div 的右下角,在它里面。我尝试了很多东西,但出于某种原因,它总是与 div 重叠并显示在外面。我做错了什么?

<style type="text/css">
body{
background-color:#f3f3f3;
}
.commentbox{
background-color: #ffffff;
width: 200px;
border-color: #D1D1D1;
border-radius: 4px;
border-style: solid;
border-width: 1px; 
padding-bottom: 9px;
padding-left: 9px;
padding-right: 9px;
padding-top: 9px;
position:relative;
}
.count{
float:right;
text-align:right;
}
</style>

<div class="commentbox">
<div class="title">Some several lines long long long long content text goes here 
</div>
<div class="count">123<br>456</div>
</div>

最佳答案

你正在 float .count 所以它不会影响它的父容器的高度。

在父级 (.commentbox) 上设置 overflow: hidden 或使用 one of the other float containing techniques所以它确实如此。

关于css - 为什么我的内容显示在 div 之外?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10062255/

相关文章:

html - 使用渐变文本作为发光字母段落格式? CSS 网络工具包

javascript - onClick() JavaScript 可见性更改

javascript - 输入数字 - 最大约束验证不起作用

javascript - 如何根据 jQuery 中父行中的列对包含子行的表进行排序

HTML 设置 Facebook 图像

javascript - 从复选框或选择选项中选择

html - 如何将 div 插入到文本将与其内联的 div

php - 隐藏输入(html 表单确认)- 服务器端脚本? (php)

jquery - Openlayers3 : Abort the Draw Interaction

html - 我可以在标题内正确对齐 CSS3 注释气泡吗?