css - div 中的内容溢出到下面的 div 中

标签 css

有人能告诉我为什么 page-view-countnum-of-days div 溢出到 top-header 中我的实现?

标记:

<div id="top-stats">
    <div id="page-view-count">count</div>
    <div id="num-of-days">num of days</div>
</div> 

<div id="top-header"This is a test</div>

CSS

#top-stats{
    width: 100%;
}

#page-view-count, #num-of-days{
    color: #666;
    text-shadow:1px 1px #FFFFFF;
    font-size:13px;
    font-weight: bold;
    padding-bottom: 5px;
}

#page-view-count{
    float:left;
}

#num-of-days{
    float:right;
}

#top-header{
    width:100%;
    display:block;
    background-color:#DBDB70;
    border-radius:3px;
}

如果我要删除 float 属性,它会很好地堆叠在 top-stats 中。

参见 fiddle

我可能遗漏了一些简单的规则,但我可能看得太近了,需要另一双眼睛......

最佳答案

#top-header{
    clear: both;
    width: 100%;
    display:block;
    background-color:#DBDB70;
    border-radius:3px;
}

Fiddle

关于css - div 中的内容溢出到下面的 div 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18426333/

相关文章:

html - 旋转表头

css - Bootstrap 按钮不显示与容器元素内联

javascript - 在 Javascript 中来回移动跟随正弦波的对象位置

wordpress - 简单的模态高度问题

css - 选项卡内的多个面板会中断选项卡

html - 如何在固定宽度的图像上覆盖表单域?

html - 都试过了,body background-image extended beyond the content

javascript - 如何将 HTML 输入添加到 sweet alert 中?

html - 右上角的日期导致页眉偏心

javascript - 无法访问 http 站点以在我的 https 站点中获取 map 标记