I'm sure this might be a simple one but I haven't figured it out yet.
How do you create a full screen fluid container and have the content, including the navigation, be centered on the page, as in a non-fluid container?
I'm just trying to get the top nav/header background to stretch across the page while keeping the content at a fixed width.
There can be two ways: By adding text-align: center; in our CSS code for the tds. By adding the “ text-center” class of Bootstrap 3 to a td element also works out of the box.
Just add the class . text-center to the parent element of the text to center content horizontally.
Make the container relatively positioned, which declares it to be a container for absolutely positioned elements. Make the element itself absolutely positioned. Place it halfway down the container with 'top: 50%'. (Note that 50%' here means 50% of the height of the container.)
The first approach uses bootstrap offset class. The key is to set an offset equal to half of the remaining size of the row. So for example, a column of size 2 would be centered by adding an offset of 5, that's (12-2)/2.
You can surround the .container
with your navigation content with another <div>
on which you add the background styling. See the following example:
.background {
background-color: #f99;
}
.content {
background-color: #9f9;
}
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="background">
<div class="container">
<div class="row">
<div class="col-xs-12 content">Content</div>
</div>
</div>
</div>
A rough method is to use the Bootstrap grid concept. Bootstrap divides your row into 12 colums. The trick consists into the insertion of a 4-black-space block before and one after your 4-space block. Example:
<div class="container-fluid">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<h2>Title</h2>
<p>Your content here</p>
</div>
<div class="col-sm-4"></div>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With