$sites = array( 'work', 'freelance', 'friend', 'personal', 'demo' ); foreach( $sites as $site ) { build('header'); build('pages'); build('footer'); build('content'); build('tables'); build('nav'); build('pages'); // It goes on and on... }
That this is needed, desperately needed, is indicated by the incredible uptake of Bootstrap. I use it in all the server software I'm working on. And it shows through in the templating language I'm developing, so everyone who uses it will find it's "just there" and works, any time you want to do a Bootstrap technique. Nothing to do, no libraries to include. It's as if it were part of the hardware. Same approach that Apple took with the Mac OS in 1984.
<!DOCTYPE html> <html> <head> <link href="css/bootstrap.min.css" rel="stylesheet"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="/css/bootstrap-responsive.css" rel="stylesheet"> <title>Bootstrap 101 Template</title> </head> <body> <h1>Hello, world!</h1> <script src="js/bootstrap.min.js"></script> </body> </html>
function make_enqueue_scriptsnstyles() { wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'make-bootstrap', get_stylesheet_directory_uri() . '/js/bootstrap.js', array( 'jquery' ) ); wp_enqueue_style( 'make-bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap.css' ); wp_enqueue_style( 'make', get_stylesheet_directory_uri() . '/style.css' ); } add_action( 'wp_enqueue_scripts', 'make_enqueue_scriptsnstyles' );
Twelve Columns
Let's imagine that we are building a normal page layout, content area on the left, sidebar on the right. The goal of Bootstrap is that you place spans that add up to twelve inside a <div class="row">
<div class="row"> <div class="span8">...</div> <div class="span4">...</div> </div>
Label | Layout width | Column width | Gutter width |
---|---|---|---|
Large display | 1200px and up | 70px | 30px |
Default | 980px and up | 60px | 20px |
Portrait tablets | 768px and above | 42px | 20px |
Phones to tablets | 767px and below | Fluid columns, no fixed widths | |
Phones | 480px and below | Fluid columns, no fixed widths |
/* Large desktop */ @media (min-width: 1200px) { ... } /* Portrait tablet to landscape and desktop */ @media (min-width: 768px) and (max-width: 979px) { ... } /* Landscape phone to portrait tablet */ @media (max-width: 767px) { ... } /* Landscape phones and down */ @media (max-width: 480px) { ... }
Class | Phones 767px and below | Tablets 979px to 768px | Desktops Default |
---|---|---|---|
.visible-phone |
Visible | Hidden | Hidden |
.visible-tablet |
Hidden | Visible | Hidden |
.visible-desktop |
Hidden | Hidden | Visible |
.hidden-phone |
Hidden | Visible | Visible |
.hidden-tablet |
Visible | Hidden | Visible |
.hidden-desktop |
Visible | Visible | Hidden |
.btn
class on an <a>
, <button>
, or <input>
elements.<div class="tabbable"> <ul class="nav nav-tabs"> <li class="active"><a href="#program" data-toggle="tab">Programmer Ryan Gosling</a></li> <li><a href="#xml" data-toggle="tab">XML Ryan Gosling</a></li> </ul> <div class="tab-content"> <div class="tab-pane active" id="program"> <img src="images/programmer.jpg"> </div> <div class="tab-pane" id="xml"> <img src="images/Goslingxml.jpeg"> </div> </div> </div>
<ul class="pager"> <li class="previous"> <?php previous_post_link('← %link'); ?> </li> <li class="next"> <?php next_post_link('→ %link'); ?> </li> </ul>
<a class="btn" data-toggle="modal" href="#myModal">Launch Modal</a> <div class="modal" id="myModal"> <div class="modal-header"> <a class="close" data-dismiss="modal">×</a> <h3>Modal header</h3> </div> <div class="modal-body"> <p>One fine body…</p> </div> <div class="modal-footer"> <a href="#" class="btn btn-primary">Save changes</a> <a href="#" class="btn" data-dismiss="modal">Close</a> </div> </div>
<div id="myCarousel" class="carousel slide"> <!-- Carousel items --> <div class="carousel-inner"> <div class="active item">…</div> <div class="item">…</div> <div class="item">…</div> </div> <!-- Carousel nav --> <a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a> <a class="carousel-control right" href="#myCarousel" data-slide="next">›</a> </div>