CSS 如何使用 Twitter Bootstrap 创建网格标题?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15573844/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 22:09:16  来源:igfitidea点击:

How to create a grid header using Twitter Bootstrap?

csstwitter-bootstrap

提问by whitneyland

How can a bootstrap grid be styled with a simple header like the picture below?

如何使用如下图所示的简单标题来设置引导网格的样式?

When I try changing the background color of the first row, the color doesn't extend to the edge of the grid because of the grid padding. When I remove the left/right grid padding, it messes up the rounded corners.

当我尝试更改第一行的背景颜色时,由于网格填充,颜色不会延伸到网格的边缘。当我删除左/右网格填充时,它会弄乱圆角。

The html looks like this:

html 看起来像这样:

<div class="container-fluid" style="border: solid 1px black; border-radius: 10px; max-width: 400px">
<div class="row-fluid">
    <div class="span3">Name</div>
    <div class="span3">Count</div>
</div>
<div class="row-fluid">
    <div class="span3">Joe</div>
    <div class="span3">10</div>
</div>
<div class="row-fluid">
    <div class="span3">Bob</div>
    <div class="span3">7</div>
</div>
</div>

enter image description here

在此处输入图片说明

采纳答案by timhc22

Does this help? rounded corners on divs with background color.

这有帮助吗?带有背景颜色的 div 上的圆角

<div class="container-fluid" style="border: solid 1px black; border-radius: 10px; max-width: 400px; padding: 0px">
    <div class="row-fluid" style="background-color: #f0f0f0; border-top-left-radius: 10px; border-top-right-radius: 10px;">
        <div class="span3">Name</div>
        <div class="span3">Count</div>
    </div>
    <div class="row-fluid">
        <div class="span3">Joe</div>
        <div class="span3">10</div>
    </div>
    <div class="row-fluid">
        <div class="span3">Bob</div>
        <div class="span3">7</div>
    </div>
</div>

回答by isherwood

This is one of those cases where you probably should be using a table. Screen reader users will appreciated it, and Bootstrap has styles built in that should help.

这是您可能应该使用表格的情况之一。屏幕阅读器用户会喜欢它,Bootstrap 内置的样式应该会有所帮助。

http://twitter.github.com/bootstrap/base-css.html#tables

http://twitter.github.com/bootstrap/base-css.html#tables