Introducing LESS© HTML5 Boilerplate
A simple, intuitive, responsive framework for building next-gen web applications
What makes it so great?
LESS is More
You get ultimate control over your UI. Start from easy standards,
as promoted by the HTML5 boilerplate, gain a native feel on mobile devices with HTML5
input types, and use cutting-edge technologies. Engage in responsive design from the
outset, watch your designs scale with em
s (rather than px
s), and
do CSS the proper way with an emphasis on grouped selectors.
Vector FTW
Customize your own icon font using Icomoon. Use up to 300 customizable icons, all in the form of a font that works with all browsers. Import any vectors from Illustrator or Photoshop.
Customizable
Using Twitter's Bower, LESS Boilerplate allows you to
get your project set up in seconds,
while always keeping the libraries you use up to date. Simply install Bower, and do
bower install
, and you'll be all set up.
100% Flexible Grid System
Built on top of LESS, LESS Boilerplate can meld into any scenario. Using this as your UI Framework, you can modify row counts, columns, column class prefix and suffixes, and even the margins between! Using Bootstrap? LESS Boilerplate can be configured to use the exact same grid classes as Bootstrap.
Customize Grid3 Colours to Rule Them All
Make customization easy for your users. Using LESS's colour functions, the framework is set to work with three colours: main, secondary, and primary. Of course, you still have the option of hard-coding your colours in... but the framework leaves you with good examples of how to build a dynamic site for your client.
Responsive
Try resizing your browser. LESS Boilerplate is built responsively, with responsive design in mind. Columns fold over, and your site is guaranteed to work on any device
What You Get
ARIA-Compliant Markup
Extend your site's accessibility by using the new ARIA roles so that those with screen
readers can better understand the structuring of your site. LESS Boilerplate ships with a
default HTML markup with the main ARIA roles: main
and nav
.
HTML5-Valid boilerplate markup
You can start your next project knowing that the markup and default styles used in LESS boilerplate are HTML5-valid. Instead of styling for older browsers (like Bootstrap), we style using the recommended W3C recommendations. Older browsers fall back using Modernizr or the HTML5 shim.
Grouped Selectors
The problem with engines like SASS (or SCSS) is that they tend to encourage lazy developers
to use directives like @extend
. But what happens after a while is that you
lose track of what styles are applied to what selectors, as the combined selector becomes
extended. LESS Boilerplate solves this issue by putting selectors together,
so that you can visualize the result. It also encourages best practices:
/* =============================================================================
Border Radius
========================================================================== */
nav, button, .btn, .box, .rounded, pre, code, aside, menu, .nav, .menu li {
.border-radius(@borderRadius); //all selectors combined. We know what's going on!
}
LESS Boilerplate is designed with UX in mind. Using HTML5 elements like the
noscript
tag, ensure your users have javascript-enabled browsers. Using
loader.js, you ensure your app doesn't get an breaking feel
when non-javascript-enabled browsers try to access your site.
Icomoon Icons the clean way
Using a new icon technique, you can avoid all the icky content
values in your CSS
by using the ready-to-use icomoon.less
file, with all icons as variables. This
makes your code much more readible and maintainable!
Code
//example module
.module {
position: relative;
.box;
&.feature-star {
&:after {
position: absolute;
font-family: "icomoon";
content: @icon-star-2;
font-size: @fontSizeLarge;
color: spin(@textColour, 40);
#transition > .transition(all @transition-time ease);
text-shadow: 0 0 @borderRadius spin(lighten(@textColour, 40), 40%);
}
&:hover {
&:after {
font-size: (@fontSizeLarge * @multiplier);
#transform > .rotate(-90deg);
content: @icon-star;
}
}
}
Result
Installation
Get Set Up in a Giffy
Setting up is easy. Simply download the files to your local
computer, do a bower install
, and you'll be good to go!
In order to get configuring LESS Boilerplate on your local machine, you will need one of two things:
- Chrome (or Chrome Canary) with the
--file-access-from-files
flag set to true. - A server like AMPPS
Windows
To set this up on Chrome on Windows, right-click on your shortcut to Chrome, navigate to the Shortcut Tab,
and on the shortcut area, append --allow-file-access-from-files
to the link. Restart Chrome.
Mac/Unix
To get the file-access-from files flag working on Chrome for Mac or unix-based operating systems, open a terminal, and type the following:
chromium --allow-file-access-from-files
Make sure that you have restarted Chrome.
Contributing
If you have some time on your hands, please message me. I need to find more people to work on this, and I am currently not able to put in as much effort as I'd like to on this amazing project. Your pull requests will be recognized immediately. If you have an idea, please make a new issue, or let me know.
Coming Soon
Looking to use Grunt, combined with YeoMan generator to quickly scaffold out new applications.
Once you have your files ready to go, you can implement your design. LESS Boilerplate has a minimal set of LESS styles to get you running quickly. These include:
Grid System
LESS Boilerplate uses a variation of Andy Taylor's newly-retired grid system. The framework has been updated to allow for generation of columns and rows, all based on the user's configuration.
To use the grid system, you will need to understand how rows and columns work. All content
that you want to space out needs to first be placed in a row
. To do this, all we
need to do is assign the class row
to any element. For example:
<div class = "row">{content goes here}</div>
Next, any elements that you want to separate in columns need to be assigned a column class. By
default, the grid system included starts out with 12 columns. So to have two
columns (or to divide the screen in two horizontal parts), we would assign the elements each
the class of sixcol
. This is because 12 / 6 = 2
:
sixcol
sixcol
threecol
threecol
threecol
threecol
threecol
threecol
sixcol
Of course, you can customize your grid system to have however many columns you want,
and even the class names. For example, you might want classes to have the
span-12
syntax like in Bootstrap. To edit the grid system,
simply change any of the variables in the variables.less
file:
/*Grid*/
@num-cols: 12;
@rowWidth: 100%;
@container-lateral-padding: @em;
@col-margin-right: 3.8%;
@col-unit: ((@rowWidth + @col-margin-right) / @num-cols);
@col-identifier: "col";
@col-name-1: "one";
@col-name-2: "two";
@col-name-3: "three";
@col-name-4: "four";
@col-name-5: "five";
@col-name-6: "six";
@col-name-7: "seven";
@col-name-8: "eight";
@col-name-9: "nine";
@col-name-10: "ten";
@col-name-11: "eleven";
@col-name-12: "twelve";
@col-name-13: "thirteen";
@col-name-14: "fourteen";
@col-name-15: "fifteen";
@col-name-16: "sixteen";
@col-name-17: "seventeen";
@col-name-18: "eighteen";
@col-name-19: "nineteen";
@col-name-20: "twenty";
@col-name-21: "twentyone";
@col-name-22: "twentytwo";
@col-name-23: "twentythree";
@col-name-24: "twentyfour";
@col-identifier-named-numbers: false; //example(true): 3col; example(false): col3
@column-selector-number-at-end: false; //example(true): threecol; example(false): colthree
Boxes
You've already seen them, but boxes offer a great way to separate your content. The most
obvious application is an aside
element.
<aside class = "box"><p>My Content Goes here</p></aside>
Output:
Boxes are, by default, rounded. You can configure all of this yourself to better suit your client.
Responsive Design
While it is true that this framework uses a "one-size-fits-all" scheme by default, it's up to you as the developer to use any media queries as necessary. That's why you will find included, a set of all possible media queries, from iPhone to Android devices. The media queries are all empty except for the one set to media query once the browser is smaller than the container size.
Helpers
LESS Boilerplate comes with a set of useful helper classes to help you quickly change the appearance of elements:
Class Name | Description |
---|---|
.pull-right |
Just adds float: right; to given element. Brings element out of flow,
to right.
|
.hide |
Hides given element. Does not show. Same as display: none; |
.show |
Sets an element to show. Reverses .hide |
.invisible |
Sets an element to be "invisible". Is still there, but cannot be seen. Doesn't work in older versions of IE. |
FAQ Frequently Asked Questions
Why LESS? I know of much better preprocessors that are more stable (SASS, Stylus, etc.). What's the difference: LESS vs. these alternatives?
While it is true that LESS is less strongly typed than its siblings (SASS, Stylus), LESS is unique in that it offers the ability of live previewing of style changes using less.js. This is also very useful, as it gives you access to the DOM, and you can set variables based off of DOM values in real-time. A big use case for this is in CMS, where the user may want to preview style changes live (to a template). To see this in action, check out warp -kickstrap for joomla or for wordpress. In these templates, styles are generated in "previews", saved, and compiled in PHP, server-side.
Otherwise, it's mostly true that SASS and Stylus beat LESS. If you are looking for the same features, minus the live editing, check out sass boilerplate.
You load Modernizr by default, but this really isn't necessary. Modernizr is hacky, and it shouldn't be used... unless absolutely necessary.
Unfortunately, if you want to use new features like HTML5 , everything can be considered a hack. While it is true that Modernizr does cause some overhead, it's also true that you can customize your build of Modernizr and use it to whatever extent you with. Using bower, you can import whichever tests you want.
So Andy Taylor says that the 1140 grid system is retired... so why are you using it here?
The reason I chose to include the 1140 grid system as my basis is that it was what I found most intuitive as I was learning grid systems. Also, I didn't use the grid system; rather, I built on top of it a base for generating new, improved grid systems. Rather than working off one media query, users are encouraged to use multiple media queries, eliminating the "one-size fits all" mentality. On the other hand, having one media query does simplify things a little bit...
I'm new to LESS. Is it worth it, over using normal CSS? What tools should I use?
If you're new to LESS, you should try google for some tutorials. Learning a preprocessor language is very useful if you plan on using CSS3 or cutting-edge features because you end up manually typing prefixes. You could use tools like prefix-free, but you will ultimately save more time by using a preprocessor with mixins.
Some tools I recommend for compiling LESS:
This "framework" uses some markup elements from Bootstrap. Is it Bootstrap-compatible?
No. LESS-Boilerplate is built with simplicity in mind. Bootstrap is not simple. Compare the following:
Bootstrap navigation
<div class="navbar">
<div class="navbar-inner">
<div class="container" style="width: auto;">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Project name</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="nav-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<form class="navbar-search pull-left" action="">
<input type="text" class="search-query span2" placeholder="Search">
</form>
<ul class="nav pull-right">
<li><a href="#">Link</a></li>
<li class="divider-vertical"></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.nav-collapse -->
</div>
</div><!-- /navbar-inner -->
</div>
Or This LESS-Boilerplate Markup:
<nav role = "main">
<ul class = "nav">
<li><a href = "#">Home <i class = "icon-home"></i></a></li>
<li><a href = "#features">Features <i class = "icon-book-2"></i></a></li>
<li><a href = "#installation">Installation <i class = "icon-database"></i></a></li>
<li><a href = "#basic-usage">Basic Usage <i class = "icon-book-3"></i></a></li>
<li><a href = "#faq">FAQ <i class = "icon-puzzle"></i></a></li>
<li><a href = "#contact">Contact <i class = "icon-mail"></i></a></li>
</ul>
</nav>
It's pretty clear that Bootstrap contains much unneeded markup code. Why do we need to have the
dropdown
class on all the items? Why not just use a bare HTML starting point like in
the example above? Also note that the Bootstrap example lacks ARIA roles.
So Andy Taylor says that the 1140 grid system is retired... so why are you using it here ?
The reason I chose to include the 1140 grid system as my basis is that it was what I found most intuitive as I was learning grid systems. Also, I didn't use the grid system; rather, I built on top of it a base for generating new, improved grid systems. Rather than working off one media query, users are encouraged to use multiple media queries, eliminating the "one-size fits all" mentality. On the other hand, having one media query does simplify things a little bit...