How do I center a row in Bootstrap? - html

I just need to know how to center the row with the columns titled, 'Hire Safely & Quickly' and 'No Staffing Agencies'. Please disregard the rest of the site as it's unfinished. Code is below, link to the dev website is here: http://staging.liberationmedical.com/new-design/
<div class="container-fluid firstcontainer" style="margin-top: 150px;">
<div class="row row-centered">
<div class="col-md-6">
<h2>Hire Safely & Quickly</h2>
<p class="icon-text1">Only credentialed professionals can use Liberation<br>Medical. As a member, you can review profiles, skills<br>and job bids and select candidates; you can hire<br>locum tenens, nurses and other contract medical<br>professionals.</p>
<p class="icon-text4-subtext"><a class="links" href="#">Sign up for free</a></p>
</div><!-- col-md-3 -->
<div class="col-md-6">
<h2>No Staffing Agencies</h2>
<p class="icon-text3">With Liberation Medical, you'll be able to engage<br>directly with contract medical professionals,
avoid<br>staffing agency fees, and evade miscommunication<br>and mis- representation. Post unlimited jobs and<br>have unlimited contracts for free!</p>
<p class="icon-text4-subtext"><a class="links" href="#">Sign up for free</a></p>
</div><!-- end col-md-3 -->
</div><!-- end row -->
</div><!-- end container-fluid -->

If you are familar with CSS you can edit the corresponding tag in your CSS-File. Have a look here: http://www.w3schools.com/cssref/pr_text_text-align.asp

First of all, your text inside your <p> tags have line breaks in it <br> which is causing your content to not fill in the entire col-md-6 and therefore giving the page a false sense of width. I would find the column width that will suit the width of your content and then offset them to center them in the page. You could do:
<div class="container-fluid firstcontainer" style="margin-top: 150px;">
<div class="row row-centered">
<div class="col-md-3 col-md-offset-3">
<h2>Hire Safely & Quickly</h2>
<p class="icon-text1">Only credentialed professionals can use Liberation<br>Medical. As a member, you can review profiles, skills<br>and job bids and select candidates; you can hire<br>locum tenens, nurses and other contract medical<br>professionals.</p>
<p class="icon-text4-subtext"><a class="links" href="#">Sign up for free</a></p>
</div><!-- col-md-3 -->
<div class="col-md-3 col-md-offset-3">
<h2>No Staffing Agencies</h2>
<p class="icon-text3">With Liberation Medical, you'll be able to engage<br> directly with contract medical professionals, avoid<br>staffing agency fees, and evade miscommunication<br> and mis-representation. Post unlimited jobs and<br>have unlimited contracts for free!
</p>
<p class="icon-text4-subtext">
<a class="links" href="#">Sign up for free</a>
</p>
</div><!-- end col-md-3 -->
</div><!-- end row -->
This should move your columns closer together and also more to the center of the page. You can play around with the offsets and column widths to get it to your liking. Just remember, 12 total columns including offsets.
One other thing that I do is to create a class called center so that I can apply that class to any element I want to make everything centered.
Like this:
.center{text-align:center;}

there is no center class in bootstrap like zurb foundation. you can use .md-offset-3 to center it

Related

Bootstrap 5 - column to have auto width while keeping to row

In Bootstrap 5 - I have various pages, sometimes 2 columns, sometimes 3.
The template system I'm using tests for the need for the third column and adds it.
<div class="container pt-5">
<div class="row gx-5">
<div class="col-sm-12 order-2 order-md-1 col-md-3">
<!-- Left column content here -->
</div>
<div class="col-sm order-1 col-md-6">
<!-- Center column content here -->
</div>
<!-- an if statement goes here which I won't bother everyone with-->
<div class="col-sm-12 order-3 col-md-3">
<!-- Right column content here -->
</div>
<!-- the if statement ends here-->
</div>
</div>
This works just fine for a three column layout. But in the template that third column (right column) is sometimes (intentionally dropped). For this two column layout, this layout still works just fine except that the center column NOW needs to be col-md-9 instead of col-md-6.
I can make the template change this, so it's "operational", but I would like to stick with layout being fully handled by bootstrap, so to speak.
I thought well fine, col-md-auto and it should resize to whatever it needs.
If I put in "col-md-auto" in the place of "col-md-6" that center column skips to a new line.
I assume there is either a way to force to row so md-auto spans 9 like I would like it to in that case OR I'm totally missing something.
As always I much appreciate everyone's help.
Please let me know if I am missing anything.
With a few comments I received I realize I see I was unclear, with the above bootstrap classes, we get the small breakpoint giving the three columns stacked, with "center" on top, "right column" in the middle, and "left column" last.
Then for anything above "sm", it gives "left column" left, "center column" center, "right column" right
The only problem being when their is no left column (which is a valid condition for this site) the center, in sizes above "sm" needs to take up the remaining space (which would be col-9 when their is no right column, or col-6 when their is).
Just change <div class="col-sm order-1 col-md-6"> to <div class="col order-1">. Now this column will have auto width.
Whole code
<div class="container pt-5">
<div class="row gx-5 bg-primary">
<div class="col-sm-12 order-2 order-md-1 col-md-3 bg-warning">
<!-- Left column content here -->
</div>
<div class="col order-1 bg-info">
<!-- Center column content here -->
</div>
<!-- an if statement goes here which I won't bother everyone with-->
<div class="col-sm-12 order-3 col-md-3 bg-body">
<!-- Right column content here -->
</div>
<!-- the if statement ends here-->
</div>
</div>
In this case I was unable to resolve just using bootstrap.
I did need to put an if statement in the templating engine.
So my final code was, the templating engine creating different templates based on two or three column.
I believe my theory was flawed, that it would be better to put this towards bootstrap (in terms of dealing with 2 or 3 columns) when it was really a decision to be made by the templating engine to then generate a 2 column layout with x bootstrap code or three column.
Thank you for eveyones time.
I thought this would be the best way to close it.

Formatting text in header tag containing glyphicon

I am trying to format a news-feed item and want to include a glyphicon to illustrate the type of news item and then a user defined text field next to it. I would like to have the text formatted such that it is indented about four spaces from the glyphicon (Second news feed item in the JSFiddle where I hardcoded it in a non-reproducible way).
I made a layout where the glyphicon was in a col-xs-1 and the rest of the screen was for the text and then zeroed out all the padding but it still too far to the right for what I would like (Third news feed item in the JSFiddle).
<div class="col-xs-12 news-feed-item-container" style="background-color:white">
<h3><span class="glyphicon glyphicon-earphone"></span>New conversation with Brett Harrsion from Firm XYZ shows there is progress being made towards the product approval</h3>
<p class="col-xs-11 col-xs-offset-1">There have been talks with the team at advisor group that lead us to believe we will be able to sell MLCDs sometime in early March</p>
</div>
<div class="col-xs-12 news-feed-divider-yellow"></div>
<div class="col-xs-12 news-feed-item-container">
<h3 style="white-space:pre"><span class="glyphicon glyphicon-earphone"></span> New conversation with Brett Harrsion from Firm XYZ shows there<br> is progress being made towards the product approval</h3>
<p class="col-xs-11 col-xs-offset-1">There have been talks with the team at Firm XYZ that lead us to believe we will be able to sell product A to them sometime in early March</p>
</div>
<div class="col-xs-12 news-feed-divider"></div>
<div class="col-xs-12 news-feed-item-container" style="background-color:white">
<div class="col-xs-1" style="padding-right:0">
<h3><span class="glyphicon glyphicon-earphone"></span></h3></div>
<div class="col-xs-11" style="padding-left:0">
<h3>New conversation with Brett Harrsion from Firm XYZ shows there is progress being made towards the product approval</h3></div>
<p class="col-xs-11 col-xs-offset-1">There have been talks with the team at advisor group that lead us to believe we will be able to sell MLCDs sometime in early March</p>
</div>
JSFiddle:
https://jsfiddle.net/schins02/r0p83uaq/
Image of feed items with styles applied =>
http://imgur.com/a/XTERt
This seems a bit picky so thanks for any help provided!
Given your needs, I would not recommend relying on .col-*-* for your positioning. Your needs are simply below what Bootstrap's Grid framework is designed for.
Instead, I would rely on wrappers with .pull-left and .pull-right to position your icon and content. I've created an example here:
http://www.bootply.com/LwfLZZ2exY
Note: My example makes use of calc() because I wasn't sure how responsive your design approach needed. You may need to adjust this (and of course any other element) to best-suit your intentions.

Boostrap not creating 4 columns

This is probably an easy one, but I'm new to bootstrap and aren't quite familiar with how it works. I have the following code to create 4 even-width columns in a row. But it keeps showing up as 4 vertically stacked columns on my laptop (1920x1080) and I'm not quite sure where I'm doing it wrong.
<div class="container">
<div class="row-fluid">
<div class="col-md-3"><!--about us feature 1st -->
<div class="about-block">
<div class="heading">
<h6>AVAILABILITY</h6>
<p>Fast Response Time<br> 15 Minutes Setup</p>
</div>
</div>
</div><!--about us feature 1st closed -->
<div class="col-md-3"><!--about us feature 2nd -->
<div class="about-block">
<div class="heading">
<h6>SPEED</h6>
<p>Average 7x Faster<br> Complete Data Coverage</p>
</div>
</div>
</div> <!--about us feature 2nd closed -->
<div class="col-md-3"><!--about us feature 3rd -->
<div class="about-block">
<div class="heading">
<h6>SAFETY</h6>
<p>Reduce Human Risk<br> No Scaffolding</p>
</div>
</div>
</div><!--about us feature 3rd closed -->
<div class="col-md-3"><!--about us feature 4th -->
<div class="about-block">
<div class="heading">
<h6>COST SAVINGS</h6>
<p>Targeted Repairs<br> Less Outage Time</p>
</div>
</div>
</div><!--about us feature 4th closed -->
</div>
</div>
UPDATE Added screenshot:
Use col-sm-3 instead, or make your <div> element wider. If you are using a container directly inside body, you shouldn't have any problem. If you are using inside another element, make sure it is wide enough.
First, try changing row-fluid class to style="float: left". Second, it is true that (in theory) the screen is divided into 12, but 3*4 might be more than 12 (margin, border, etc.). If the first part renders three columns and the 4th underneath, try reducing the size of the columns by setting, for instance, width=24%.

How to centered bootstrap col-md-4 and col-md-5 in the middle of the page?

I have two bootstrap items one col-md-5 and one col-md-4. But i want to centered these two items in the middle of the page, both of them. Now my col-md-4 is at the left side of the page and the col-md-5 is at the middle of the page. Has anyone an idea how to centered these two items without use only margin.
<div class="col-md-4">
<div class="klantcases">
<h2>Company</h2>
<li>Over ons</li>
<li>Kernwaarden</li>
<li>Missie en visie</li>
<li>Nieuws</li>
<li>Blog</li>
<li>Development Blog</li>
<li>Marketing Blog</li>
<li>Development</li>
<li>Marketing</li>
<li><a href="#">Werken bij ons></li>
</div>
<div class="col-md-5">
<div class="blogpreview">
<img src="img/kan.png" alt="kan" /><h1>The latest from our</br>
DEVELOPMENT BLOG</h1>
<img src="img/bloglaptop.jpg" alt="bloglaptopcode" />
<div class="bloginfo"><h2>Woensdag 15 april 2015 - 12:05</h2></br></br>
<h1>CSS styleable, vector based icons on every device (even IE8)</h1>
<p>Icons have always been an important part of an interface. They allow the user to recognize certain actions with only a glance. In this blog, we will look for a complete and closing solution to render css-styleable icons that are supported by older browsers while still looking great on modern retina displays.</p>
<h3 class="leesmeer">LEES MEER</h3>
</div>
<div class="meer">
<h2>Maandag 13 april 2015 - 13:19</h2>
<h1>Inline video on the iPhone</h2>
<p>video has come a long way. We went from nitrate film, tape and VHS to digital video. From black and white tubes to full color 4k flatscreen televisions. And from static desktop environments to video more and more being something that you take with you by watching it on your mobile device. </p>
<h3 class="leesmeer">LEES MEER</h3>
</div>
<div class="meer">
<h2>Maandag 30 maart 2015 - 18:30</h2>
<h1>Video in email: today or tomorrow?</h2>
<p>You can and should be using video in email today! Video in email often is "the" missing link in business to consumer email communication. We did a lot of technical research and development and want to share some of the results with you today. </p>
<h3 class="leesmeer">LEES MEER</h3>
</div>
<img src="img/pfoon.png" alt="pfoon" /> <h1>The latest from our</br>
MARKETING BLOG</h1>
<img src="img/iphone.jpg" alt="iphonehand" />
<div class="bloginfo2"><h2>Woensdag 15 april 2015 - 12:05</h2></br></br>
<h1>CSS styleable, vector based icons on every device (even IE8)</h1>
<p>Icons have always been an important part of an interface. They allow the user to recognize certain actions with only a glance. In this blog, we will look for a complete and closing solution to render css-styleable icons that are supported by older browsers while still looking great on modern retina displays.</p>
<h3 class="leesmeer">LEES MEER</h3>
</div>
<div class="meer">
<h2>Maandag 13 april 2015 - 13:19</h2>
<h1>Inline video on the iPhone</h2>
<p>video has come a long way. We went from nitrate film, tape and VHS to digital video. From black and white tubes to full color 4k flatscreen televisions. And from static desktop environments to video more and more being something that you take with you by watching it on your mobile device. </p>
<h3 class="leesmeer">LEES MEER</h3>
</div>
<div class="meer">
<h2>Maandag 30 maart 2015 - 18:30</h2>
<h1>Video in email: today or tomorrow?</h2>
<p>You can and should be using video in email today! Video in email often is "the" missing link in business to consumer email communication. We did a lot of technical research and development and want to share some of the results with you today. </p>
<h3 class="leesmeer">LEES MEER</h3>
</div>
</div>
You can offset columns in bootstrap. See Docs.
By using a class such as, col-md-offset-4 you can push your columns across the page.
In your case you would need to adjust your columns to make up an even total, e.g. col-md-4 and col-md-6, and then add col-md-offset-1 to offset the first column by 1 column.
Since the Bootstrap default grid has 12 columns, you cannot center the 9 columns grid with the default Bootstrap offsets. So all you need to do is create a custom 1.5 offset (which left margin would be equal to 1.5/12*100% = 12.5%) and apply it to the .col-md-4 container:
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-custom">...</div>
<div class="col-md-5">...</div>
</div>
<!-- / .row -->
</div>
<!-- / .container -->
#media(min-width: 992px && max-width: 1199px) {
.col-md-offset-custom {
margin-left: 12.5%;
}
}
JSFiddle: http://jsfiddle.net/Lq06L4hb/2/

Name elements used as descriptions for complex layout

I have a Project where many developers are going to inherit my code. I am working mainly on the HTML, CSS and some JavaScript. I am using Foundation 5 and many of the developers (Mostly NodeJS and JavaSCript programmers) are unfamiliar with Responsive Frameworks like Foundation & Bootstrap. They do understand media queries and css very well, but simply have not worked with the 12 column layout etc..
I have a few very complex layout where there are nested grids. I have commented the heck out of these areas so that they will understand if I'm gone or not around to help with something later. I am using comments in conjunction with name="Content-Container", or name="Left-Column" & name="Right-Column". So I am using the name element as kind of description. The pages are super easy to read and understand now despite the complex hierarchy.
I have a comment at the top of each page that says:
<!-- README: This page contains many comments to aid in debugging, etc.. -->
<!-- There are many div's with a name element. These name elements were not-->
<!-- made to be targeted with css. These name elements are descriptions -->
<!-- to aid with understanding their purpose. -->
IS this a good idea? Am I opening up a can of worms by giving them alternate ways of targeting these divs when I'm gone that shouldn't be used when they should instead be using the existing classes and ID's?
Should I not use these names and instead only use commenting? I have never worked with a large team. They seem to understand that I have brought some order and organization to their code. I have completely restructured their entire site, but I don't want to add more complexity if not needed or the ability for them to use these unintentionally.
Your comments are encouraged, I'm seeking advice from those who are used to working on larger teams where they may see me shooting myself in the foot here.
BELOW IS A SAMPLE OF WHAT I'M DOING:
<!--All Content goes inside here. At the time of this writing it
contains two columns that will stack vertically on small screens-->
<div class="row" name="Content-Container">
<!--This is the left hand column that takes up 7 of 12 columns-->
<div class="medium-7 columns" name="Left-Column">
<!--This starts a row to hold many 12 column content containers (Search, Filter, Image & Search Results)-->
<div class="row" name="Left Column Row-Container">
<!-- Start Search Row-->
<div class="medium-12 columns">
<div class="searchWikiMargin">
<form name="searchForm" action="/">
<div class="row collapse">
<div class="small-10 columns">
<input type="search" name="q" id="autoSearch" placeholder="Search local and beyond..." class="placehold">
</div>
<div class="small-2 columns">
Search
</div>
</div>
</form>
</div>
</div>
<!-- End Search Row-->
<!-- Start Filter Navigation Row-->
<div class="medium-12 columns">
<dl class="sub-nav">
<dt>Filter:</dt>
<dd class="active">Web</dd>
<dd>Images</dd>
<dd>News</dd>
<dd>All</dd>
</dl><hr>
</div>
<!-- End Filter Navigation Row-->
<!-- Start Mobile Wiki Results Row ~NO TOP MARGIN SHOWS ONLY ON SMALL SCREENS-->
<div class="small-12 columns show-for-small-only">
<div>
<img src="...">
</div>
</div>
<!-- End Mobile Wiki Results Row-->
<!-- Start Image Results Row-->
<div class="medium-12 columns">
<h5>Image Results For tj hooker</h4>
<ul class="small-block-grid-3">
<li><img class="th" src="eb_images/tj-01.jpg" height="50"></li>
<li><img class="th" src="eb_images/tj-02.jpg" height="50"></li>
<li><img class="th" src="eb_images/tj-03.jpg" height="50"></li>
<li><img class="th" src="eb_images/tj-04.jpg" height="50"></li>
<li><img class="th" src="eb_images/tj-05.jpg" height="50"></li>
<li><img class="th" src="eb_images/tj-06.jpg" height="50"></li>
</ul>
</div>
<!-- End Image Results Row-->
<!-- Start Search Results Row-->
<div class="medium-12 columns">
<h5>Image Results For tj hooker</h4>
<img src="eb_images/tjresults.png">
</div>
<!-- End Search Results Row-->
</div><!--End "Left-Column-Row-Container" -->
</div><!--End "Left-Column" -->
<!--This is the right hand column that takes up 5 of 12 columns-->
<div class="medium-5 columns show-for-medium-up" name="Right-Column">
<!--This starts a row to hold one 12 column content container (Wiki)-->
<div class="row" name="Right-Column-Row-Container">
<!-- Start Mobile Wiki Results Row ~HAS TOP MARGIN & SHOWS ONLY ON MEDIUM & LARGE (DESKTOP) SCREENS-->
<div class="medium-12 columns">
<div class="searchWikiMargin">
<img src="eb_images/tjwiki.png">
</div>
</div>
<!-- End Mobile Wiki Results Row-->
</div><!--End "Right-Column-Row-Container"-->
</div><!--End "Right-Column"-->
</div><!--End Row "Content-Container"-->
This is just one portion of the page.
"Am I opening up a can of worms by giving them alternate ways of targeting these divs "
YES. My reasoning: in the long run you will eventually want all of that extra stuff to lose its usefulness (you want your team to eventually function without extra help).
You answered your own question, I believe.
"Should I not use these names and instead only use commenting?"
YES. Use extra comments, comment the heck out of it. Comments don't change code.