Niffyy
Niffyy

Reputation: 45

Bootstrap Containers

I'm new to coding so sorry if this seems like an obvious question.

When using bootstrap 1) can I have more than 1 container? if so how do I go about styling them separately if they both have to be called container ?

Thanks!

Upvotes: 3

Views: 82

Answers (2)

Carol Skelly
Carol Skelly

Reputation: 362780

Yes, you can have as many container or container-fluid as needed.

Add a custom CSS class to the containers to stylize..

<div class="container-fluid">...</div>
<div class="container-fluid someclass">...</div>

.someclass {
    background-color:#eee;
}

http://www.codeply.com/go/8vDhaX4kKV

Upvotes: 2

Richard Hamilton
Richard Hamilton

Reputation: 26444

The Bootstrap website says this

Easily center a page's contents by wrapping its contents in a .container. Containers set width at various media query breakpoints to match our grid system.

Note that, due to padding and fixed widths, containers are not nestable by default.

You can have multiple containers, but you should not nest them.

Now assuming you do have more than one, there are multiple ways you could style them.

  1. You could assign an id to a container like so <div class="container" id="container1">. You can then reference this with the id selector (#container1)
  2. You could use pseudoselectors. .container:first-of-type, .container:nth-child(3) etc

Upvotes: 1

Related Questions