Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a grid header using Twitter Bootstrap?

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:

<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

like image 542
whitneyland Avatar asked Mar 22 '13 15:03

whitneyland


People also ask

Does Twitter still use Bootstrap?

At Twitter, Bootstrap has quickly become one of our many go-to front-end tools when starting new applications and sites.

Does Bootstrap support grid?

Bootstrap's grid system allows up to 12 columns across the page.

How do I customize Bootstrap grid?

Just check the Grid System block on the Customize page. The @grid-columns field allows to set a different number of columns, and the @grid-gutter-width field lets you change the gutter width. Customizers are convenient when bootstrap. css is the only file you need and when you don't work with preprocessors.

How do I make 5 columns in Bootstrap 4?

Populate the 'row' div with 5 divs with class 'col'. Because Bootstrap 4.0+ grid system has now shifted to Flexbox, the columns will arrange by themselves into five equally sized DOM elements.


2 Answers

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

<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>
like image 75
timhc22 Avatar answered Oct 11 '22 13:10

timhc22


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.

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

like image 32
isherwood Avatar answered Oct 11 '22 12:10

isherwood