Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap column full content background-color

This is what I want to do : enter image description here

And this is what I have : enter image description here

And this is my code :

Html

<div class="row">
  <div class="col-md-4">col-md-4</div>
  <div class="col-md-6">col-md-6 ...</div>
  <div class="col-md-2">col-md-2</div>
</div>

Css

.col-md-4,.col-md-2 {
background-color: #e3e3e3;
}

.col-md-6 {
background-color: #f5f3f3;
}

I checked other questions on the subject but I'm not satisfied with the answers... can someone help me to improve my code ? thank you !

like image 436
Lucas B Avatar asked Apr 19 '15 09:04

Lucas B


People also ask

How can I set background color of a div in Bootstrap?

We can add background color to a div by simply adding class “bg-primary”, “bg-success”, “bg-danger”, “bg-info”, and many more as shown in the following examples.

How do I change the background color of a row in Bootstrap?

Using pre-defined classes, we can change the color of table cells and table rows. In order to change the color of the table row, we need to specify in <tr> tag with the required class & for changing the color of the table row then specify it inside <td> tag with the required class.

How do I make the background transparent in Bootstrap 4?

Creating a transparent navbar is very easy - just don't add a color class . bg-* to the navbar. In this case, the Navbar will take the color of the parent's background color.


2 Answers

Look here in JSFiddle...

I hope you are looking for this output. If yes then try the following code:

Ouput of the JSFiddle code

HTML:

<div class="row">
    <div class="col-md-4 row-height">
        <span>col-md-4</span>
    </div>
    <div class="col-md-6 row-height">
        col-md-6
    </div>
    <div class="col-md-2 row-height">
        col-md-2
    </div>
</div>

And CSS:

.row {
    padding: 100px;
}

.row-height {
    height: 70px;
    text-align: center;
    padding-top: 25px;
}

.col-md-4,.col-md-2 {
    background-color: #e3e3e3;
}

.col-md-6 {
    background-color: #f5f3f3;
}

.col-md-4 {
    border-radius: 15px 0 0 15px;
}

.col-md-2 {
    border-radius: 0 15px 15px 0;
}

You can modify the CSS the way you want and sizes in the styles according to the content.

Hope this helps...

like image 121
Benison Sam Avatar answered Oct 06 '22 18:10

Benison Sam


You could color the entire .row and then the middle column separately..

.row {
    background-color: #e3e3e3;
    border-radius: 15px;
}

.col-md-6 {
    background-color: #f5f3f3;
}

http://codeply.com/go/FXSkrecwwI

like image 44
Zim Avatar answered Oct 06 '22 18:10

Zim