<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Responsive Design Archives - Michael Soriano</title>
	<atom:link href="https://michaelsoriano.com/tag/responsive-design/feed/" rel="self" type="application/rss+xml" />
	<link>https://michaelsoriano.com/tag/responsive-design/</link>
	<description>I turn code into captivating user experiences for the web</description>
	<lastBuildDate>Thu, 14 Nov 2013 03:57:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.4</generator>
	<item>
		<title>Exploring the Bootstrap 3.0 Grid System</title>
		<link>https://michaelsoriano.com/exploring-the-bootstrap-3-0-grid-system/</link>
					<comments>https://michaelsoriano.com/exploring-the-bootstrap-3-0-grid-system/#comments</comments>
		
		<dc:creator><![CDATA[Michael Soriano]]></dc:creator>
		<pubDate>Thu, 14 Nov 2013 03:57:06 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Bootstrap]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[Responsive Design]]></category>
		<guid isPermaLink="false">http://fearlessflyer.com/?p=3767</guid>

					<description><![CDATA[<p>Understanding what this framework can do for your next responsive site The idea of a grid system has been around since the 960.gs framework days. Web designers from all over the world began realizing the importance of pixel perfect alignment, gutter spacing and the rule of thirds. Gone are the days of grid-less web pages. [&#8230;]</p>
<p>The post <a href="https://michaelsoriano.com/exploring-the-bootstrap-3-0-grid-system/">Exploring the Bootstrap 3.0 Grid System</a> appeared first on <a href="https://michaelsoriano.com">Michael Soriano</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Understanding what this framework can do for your next responsive site<br />
The idea of a grid system has been around since the <a href="http://960.gs/">960.gs</a> framework days. Web designers from all over the world began realizing the importance of pixel perfect alignment, gutter spacing and the rule of thirds. Gone are the days of grid-less web pages. And yes, things were great. Up until recently. <strong>Responsive web design</strong> was born.<br />
<img fetchpriority="high" decoding="async" src="https://michaelsoriano.com/wp-content/uploads/2013/11/bstrap.jpg" alt="bstrap" width="600" height="392" class="alignnone size-full wp-image-3768" /><br />
The problem was 960.gs, along with older frameworks had static page widths. Since we are now designing for multiple screen sizes, web frameworks had to adapt quickly.<br />
Enter Zurb <a href="http://foundation.zurb.com/">Foundation</a>. The first responsive framework that had web designers pee in their pants. Big sites such as <a href="http://www.esquire.co.uk/">Esquire UK</a>, <a href="http://upmagazine-tap.com/">Up Magazine</a> and <a href="http://thenextweb.com/">The Next Web</a> redesigned and we kept resizing our browsers in awe. We were simply amazed on how elements of the pages shifted gracefully. Horizontal scrollbars were a thing of the past and modern web design became &#8211; well, more modern.<br />
Now we have the latest and the greatest Bootstrap 3. Despite their awesome <a href="http://getbootstrap.com/css/">documentation</a>, my focus is to elaborate on just the heart of the framework &#8211; the grid system.<br />
Let&#8217;s dive in and see what Bootstrap&#8217;s grid system is all about.</p>
<h3>The Basic .col-xx-xx Classes</h3>
<p>Bootstraps column classes are what makes up the individual columns of the grid. It&#8217;s main purpose is to align your components into &#8211; you guessed it, columns. They&#8217;re designed to have 3 sections:<br />
<img decoding="async" src="https://michaelsoriano.com/wp-content/uploads/2013/11/col-classes.jpg" alt="col-classes" width="557" height="223" class="noborder alignnone size-full wp-image-3769" /><br />
The prefix part &#8220;col&#8221; &#8211; just organizes all the col classes together, sort of like a namespace. And if you&#8217;ve worked with other frameworks in the past, the 3rd section &#8220;12&#8221; just tells us to occupy 12 columns out of the maximum 12. Pretty basic right?<br />
But what about the 2nd part? In our example, it&#8217;s the &#8220;lg&#8221;. This tells the browser to primarily use this for large screens only (default is 1170 pixels and above). Meaning, since we can use multiple classes on any element, <strong>we can <u>now</u> design for multiple sizes of the screen</strong>. Pretty powerful eh?<br />
<strong><u>So how does it do that?</u></strong><br />
So if you investigate the css, and look for that particular class (.col-lg-12), you will see that it&#8217;s enclosed in a media query:</p>
<pre>
@media (min-width: 1200px) {
.col-lg-12 {
    width: 100%;
  }
}
</pre>
<p>As a matter of fact, ALL of the &#8220;lg&#8221; classes are inside this media query. So the rule only applies to a specific screen resolution. The rest of the sizes (md for 970px, sm for 768px and xs for less than 768px) contains the rules for its respective classes. Pretty forward thinking right?<br />
<strong><u>Show me an example of its usefulness:</u></strong><br />
A common scenario is a two-column layout, with content on the left and sidebar on the right. With just a single class applied to both areas: red div has a class of <strong>col-lg-9</strong> and green div has <strong>col-lg-3</strong>.<br />
But most of the time &#8211; your sidebar&#8217;s content is not ready for a full page width in medium and small view ports. So you wish the sidebar doesn&#8217;t snap to the bottom right away right?<br />
<img decoding="async" src="https://michaelsoriano.com/wp-content/uploads/2013/11/example1.gif" alt="example1" width="650" height="384" class="alignnone size-full wp-image-3770" /><br />
<strong>The solution:</strong> apply multiple .col classes into the same divs (one for each of the view port sizes). Take a look at the next example &#8211; where we apply a different column number ONLY on the extra small (<strong>.col-xs-12</strong>).<br />
<img decoding="async" src="https://michaelsoriano.com/wp-content/uploads/2013/11/example2.gif" alt="example2" width="650" height="384" class="alignnone size-full wp-image-3771" /><br />
You see how the divs retained their 2 column layout all the way until the extra small view port is reached. Only then, did our sidebar snap to the bottom at full width. So you see how <strong>useful</strong> this is yet?</p>
<h3>Classes &#8220;row&#8221; and &#8220;container&#8221;</h3>
<p>Let&#8217;s jump out of the columns and look at the classes that wrap them. We have two important classes that do just that.<br />
<strong><u>.row</u></strong><br />
Just as the word describes &#8211; a row is something that is on one horizontal layer. Similar to a &#8220;record&#8221; in a database, or a &#8220;row&#8221; in a table. In Bootstrap, if you want elements to be in one horizontal layer &#8211; use a class <strong>.row</strong>.<br />
<img decoding="async" src="https://michaelsoriano.com/wp-content/uploads/2013/11/example3.gif" alt="example3" width="650" height="384" class="alignnone size-full wp-image-3772" /><br />
The dark grey divs both have a class &#8220;.row&#8221;. A <strong>row</strong> basically acts as a traditional div tag, but instead can be applied as a class. I&#8217;ve used class .row on a header or footer tag &#8211; and it works really well.<br />
<strong><u>.container</u></strong><br />
Ideally, you add your HTML elements that need to be grouped together inside a class .container. The &#8220;max-width&#8221; properties for each break point (the media queries) are defined in this class. It is a very important class. One that is required to make things work the way they do.<br />
According to Bootstrap&#8217;s docs, containers are:</p>
<blockquote><p>
Easily center a page&#8217;s contents by wrapping its contents in a .container. Containers set max-width at various media query breakpoints to match our grid system.
</p></blockquote>
<p>Containers also follow the default padding rule of 15 pixels on each side. So the contents are automatically flushed together with just the right amount of gutter space all the time.</p>
<h3>How does Nesting work?</h3>
<p>Nesting means adding more .col classes inside of existing .col classes. Most of the time, you would need to add a .row class first &#8211; before nesting your .col divs inside in order to see desired results.<br />
<strong>So when do you need to nest?</strong><br />
All the time! If you inspect most HTML documents &#8211; it&#8217;s already a series of nested DOM elements so nesting your .col classes is already expected behavior. Although in Bootstrap, nesting will save you a lot of work calculating and deciding how wide a column has to be.<br />
<img decoding="async" src="https://michaelsoriano.com/wp-content/uploads/2013/11/example4.gif" alt="example4" width="650" height="384" class="alignnone size-full wp-image-3773" /><br />
See both green divs have that have .col-lg-6 classes? These are nested inside the red div (the parent div).  Also, notice that a nested .col-lg-6 class takes up 50% of the parent div&#8217;s width. In other words, all you really need to remember is the 12 grid rule &#8211; no matter how deep the nesting goes.<br />
Note that I also applied the multiple classes technique (discussed above) to the child classes shown in the screenshot above. This is so that when resized, both div&#8217;s retain it&#8217;s 6 column width &#8211; until the last view port kicks in.</p>
<h3>Pushing, Pulling and Offsetting</h3>
<p>For even deeper customization of the grid elements, Bootstrap allows you to shift the columns around. Push and pull classes allow you to move the column # times to the left (also know as pull), or # times to the right (push).<br />
<img decoding="async" src="https://michaelsoriano.com/wp-content/uploads/2013/11/ordering.jpg" alt="ordering" width="475" height="228" class="noborder alignnone size-full wp-image-3775" /><br />
So consider the markup below. Even though the green div is written right above the red div, the push and pull classes allows us to order them as if they were otherwise.</p>
<pre>
<div class="col-md-4 col-md-push-4"><p>green pushed 4</p></div>
<div class="col-md-4 col-md-pull-4"><p>red pulled 4</p></div>
</pre>
<p>The code above makes it so the divs appear in the browser in a different order.<br />
<img decoding="async" src="https://michaelsoriano.com/wp-content/uploads/2013/11/push-pull.png" alt="push-pull" width="600" height="226" class="alignnone size-full wp-image-3776" /><br />
<strong><u>What makes it work?</u></strong><br />
If you inspect the push and pull classes, it utilizes the right and left property respectively &#8211; in percents. Since everything in Bootstrap is positioned relatively, using left and right will automatically just work.</p>
<pre>
@media (min-width: 992px)
   .col-md-pull-4 {
      right: 33.33333333333333%;
   }
   .col-md-push-4 {
      left: 33.33333333333333%;
   }
}
</pre>
<p><strong><u>Offsets</u></strong><br />
Offsetting classes is similar to push and pull classes &#8211; except for the &#8220;offset&#8221; keyword in the class name. Also similar to push and pull, the number in the class tells the browser how many columns to offset the element.<br />
<img decoding="async" src="https://michaelsoriano.com/wp-content/uploads/2013/11/offsetting.jpg" alt="offsetting" width="525" height="235" class="alignnone noborder size-full wp-image-3774" /><br />
The difference with offsetting is that it uses the margin left property. So if your element is right next to another element &#8211; it will simply push itself against it by the designated percentage. See the code below for a <strong>.col-md-offset-4</strong> class:</p>
<pre>
@media (min-width: 992px)
 .col-md-offset-4 {
    margin-left: 33.33333333333333%;
 }
</pre>
<p>You see how this can be useful? You can simply apply this class to whichever you want to offset and still retain the responsive margins effectively. Pretty good right?</p>
<h3>Visibility Classes</h3>
<p>Although this has nothing to do with the grid, I thought it is worth a mention. We&#8217;ve all worked with a system that has a default class for a &#8220;display:none&#8221;. Well not only does Bootstrap have this (it&#8217;s called .hidden), but they&#8217;ve taken it an extra step. I like to call them the &#8220;visibility&#8221; classes.<br />
These classes do just that &#8211; controls the visibility of elements &#8211; across multiple views. Now, when designing your web site, you just now have to pick which elements to show, hide in large, medium and small views &#8211; then simply apply the visibility classes. The table below (taken from Bootstrap&#8217;s website) explains what the classes do in specific view ports.</p>
<style>
.is-visible {
color: #468847;
background-color: #dff0d8 !important;
}
</style>
<table class="table table-bordered table-striped responsive-utilities" style="margin-top:35px; margin-bottom:45px;">
<thead>
<tr>
<th></th>
<th>
              Extra small devices<br />
              <small>Phones (&lt;768px)</small>
            </th>
<th>
              Small devices<br />
              <small>Tablets (≥768px)</small>
            </th>
<th class="hidden-xs">
              Medium devices<br />
              <small>Desktops (≥992px)</small>
            </th>
<th class="hidden-xs">
              Large devices<br />
              <small>Desktops (≥1200px)</small>
            </th>
</tr>
</thead>
<tbody>
<tr>
<th><code>.visible-xs</code></th>
<td class="is-visible">Visible</td>
<td class="is-hidden">Hidden</td>
<td class="is-hidden hidden-xs">Hidden</td>
<td class="is-hidden hidden-xs">Hidden</td>
</tr>
<tr>
<th><code>.visible-sm</code></th>
<td class="is-hidden">Hidden</td>
<td class="is-visible">Visible</td>
<td class="is-hidden hidden-xs">Hidden</td>
<td class="is-hidden hidden-xs">Hidden</td>
</tr>
<tr>
<th><code>.visible-md</code></th>
<td class="is-hidden">Hidden</td>
<td class="is-hidden">Hidden</td>
<td class="is-visible hidden-xs">Visible</td>
<td class="is-hidden hidden-xs">Hidden</td>
</tr>
<tr>
<th><code>.visible-lg</code></th>
<td class="is-hidden">Hidden</td>
<td class="is-hidden">Hidden</td>
<td class="is-hidden hidden-xs">Hidden</td>
<td class="is-visible hidden-xs">Visible</td>
</tr>
</tbody>
<tbody>
<tr>
<th><code>.hidden-xs</code></th>
<td class="is-hidden">Hidden</td>
<td class="is-visible">Visible</td>
<td class="is-visible hidden-xs">Visible</td>
<td class="is-visible hidden-xs">Visible</td>
</tr>
<tr>
<th><code>.hidden-sm</code></th>
<td class="is-visible">Visible</td>
<td class="is-hidden">Hidden</td>
<td class="is-visible hidden-xs">Visible</td>
<td class="is-visible hidden-xs">Visible</td>
</tr>
<tr>
<th><code>.hidden-md</code></th>
<td class="is-visible">Visible</td>
<td class="is-visible">Visible</td>
<td class="is-hidden hidden-xs">Hidden</td>
<td class="is-visible hidden-xs">Visible</td>
</tr>
<tr>
<th><code>.hidden-lg</code></th>
<td class="is-visible">Visible</td>
<td class="is-visible">Visible</td>
<td class="is-visible hidden-xs">Visible</td>
<td class="is-hidden hidden-xs">Hidden</td>
</tr>
</tbody>
</table>
<h3>Conclusion</h3>
<p>I believe we&#8217;ve looked at the core classes that will get you up and running with Bootstrap&#8217;s grid system. This alone, if used properly &#8211; will save you countless hours of development time. Don&#8217;t forget to read up on the rest of Bootstrap&#8217;s many features such as the built-in components, Javascript plugins and of course, the rest of the styles. Good luck and have fun coding!<br />
Last of all, I would like to keep this an open discussion. If there&#8217;s anything that you would like to add, please leave a comment. I will be more than happy to answer questions or append to the article.</p>
<p>The post <a href="https://michaelsoriano.com/exploring-the-bootstrap-3-0-grid-system/">Exploring the Bootstrap 3.0 Grid System</a> appeared first on <a href="https://michaelsoriano.com">Michael Soriano</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://michaelsoriano.com/exploring-the-bootstrap-3-0-grid-system/feed/</wfw:commentRss>
			<slash:comments>21</slash:comments>
		
		
			</item>
	</channel>
</rss>
