Join over 55,891 Subscribers Today! FREE UPDATES!
Get The Only Freelancer crash course you will ever need to read!
This is the second part of my tutorial on How to Build a Website Using Twitter Bootstrap and SASS where we shall be customizing the Twitter Bootstrap-based web page using SASS. Just to set the context right, we will be starting out where we left off in the previous tutorial. If you haven’t seen it yet, please check it out and work through it. There you will learn how to setup your system for TBS, Ruby, and Compass.
In this tutorial we will be furnishing our webpage from the last tutorial using SASS. By the end of this tutorial you will be at the next level of developing beautiful websites and applications!
Lets remember that we are using the same file set which we used in the first part of this tutorial. Also, please make sure all the setup guidelines are being followed. Primarily, the Compass compiler should be watching our entire folder to make sure all the changes in the SASS files are being converted to the relevant CSS file.
We can customize the above page in multiple ways:
The latter is always preferable (we discussed in the first part of the tutorial, that it’s always recommended to use a separate stylesheet file to override rules of any plugins or frameworks), because when it comes to multiple theming of the page, we just have to change the custom CSS file to another one in order to apply different skins to the layout. So lets create a SASS file (extension of a sass file is .scss) and place it in the ‘sass’ folder. Since the page talks about 1stwebdesigner, I’m naming it ’1wd.scss’, and including it in the HTML. Also make sure you are including it after the line which includes all bootstrap styles. Our folder structure now looks like:

As a first step towards customization I always prefer adding a mother class to the body tag of the page, so that I can always group all the custom rules by referring to that class. So, lets start by giving the body tag of our HTML page a class – ‘fwd’. This helps us to maintain a first level of grouping in terms of selectors and makes sure we don’t override the bootstrap selectors directly.
We will also be using a pinch of CSS3 in our styles. So lets include the CSS3 mixins in our .scss files so that we can make use of most of the CSS3 features easily using a single line of code.
Lets start with the header.
Here is a comparison of our current header and the customized one:
The key changes that we’ll be doing here are:
.brand{
text-indent:-999px;
width:169px;
height:26px;
padding:0;
margin:5px 0 0 0;
background:url(http://cdn1.1stwebdesigner.com/wp-content/themes/1stwd/img/1wd-logo-rd.png)
no-repeat center center;
}
.navbar{
.navbar-inner{
background:#eee;
border-bottom:solid 1px #ccc;
.nav{
margin-left:20px;
li{
a{
padding:5px;
margin:5px 5px 0 0;
@include border-radius(5px);
&:hover{
background:#000;
};
}
}
}
.brand{
text-indent:-999px;
width:169px;
height:26px;
padding:0;
margin:5px 0 0 0;
background:url(http://cdn1.1stwebdesigner.com/wp-content/themes/1stwd/img/1wd-logo-rd.png)
no-repeat center center;
}
}
}
Next is the hero unit
Here is a comparison of our current hero-unit and the customized one:


The key changes that we’ll be doing here are (the final code for this section is given towards the end of this bulleted section):
.hero-unit{
background:#464646;
color:#fff;
h1{
@include text-shadow(#000 1px 5px 10px);
span{
color:#F5821F;
}
}
.btn-info{
padding:15px;
font-size:1.2em;
}
form{
@include border-radius(10px);
background:#6d6b6b;
label{
font-weight:bold;
font-size:1.2em;
&.checkbox{
font-weight:normal;
font-size:1em;
color:#2d2d2d;
}
}
input{
background:#464646;
border:solid 1px #545252;
@include box-shadow(inset #2d2d2d 1px 0px 3px);
color:#8b7b6c;
}
}
}
Now comes the thumbnail section
Here is a comparison of our current thumbnail section and the customized one:
The key changes that we’ll be doing here are (the final code for this section is given towards the end of this bulleted section):
.thumbnail{
@include border-radius(10px);
background:#55626B;
.caption{
position:relative;
color:#ccc9c9;
h5{
position:absolute;
top:-19px;
left:10px;
font-size:2em;
color:#fff;
@include text-shadow(#000 1px 5px 10px);
}
}
}
Finally the footer
I am just adding a custom pattern to the footer, add a border-radius and will be increasing the padding of the container to 20px. Please refer to the code of footer below:
footer{
padding:20px;
margin-top:30px;
@include border-radius(10px 10px 0 0);
color:#fff;
background:url(http://cdn1.1stwebdesigner.com/wp-content/themes/1stwd/img/bg_header.jpg) repeat left top;
}
Finally after all the customization and coding, here is how our customized page looks:
This is just an intro to the power of SASS and TBS together. In the CSS file that we have used we can make use of variables effectively by storing color values in them and then importing the variable CSS to the main stylesheet at the beginning. With the complexity of each page, all the features of SASS can be leveraged in a much better way. Mixins, Extend, Variables and much more are in store for us to explore and implement.
Get started with this if you are planning to plunge into the world of SASS and wait for more to come your way. I’d appreciate your feedback on my approach and on this tutorial to help me improve!
Get The Only Freelancer crash course you will ever need to read!
A User Experience designer with specialized experience in front-end engineering, i have over time developed a strong passion in being associated with product-based teams. The unified goal and challenges that a product's life cycle offers is simply unbeatable! For me, proficiency in tools takes the back seat when it comes to User Experience Design, and i believe one has to be passionate and equally agile to be a key part of the team. I bring to the table the diverse hands-on experience on various facets of experience design, and have played key roles in the team bridging the gap between design, dev and biz groups within product teams. My vision is to be the key hand behind the UX design of a world-class product in a team of passionate and uber-smart techies and designers! Specialties: Information Architecture, Wireframing, Heuristic Evaluation, Web standards, Interaction design, Semantic markup, OO CSS, Usability Review
Monday, July 23rd, 2012 08:46
Great stuff!
Wanted to just drop by and appreciate you for helping more people adopt bootstrap.
ClickDesk is website designed using Twitter Bootstrap.
We blogged about it here – Why did ClickDesk choose Twitter Bootstrap? – http://blog.clickdesk.com/why-did-clickdesk-choose-twitter-bootstrap/
Thursday, July 19th, 2012 06:44
Why there is no html5 elements like: nav and header?
Tuesday, July 17th, 2012 06:46
Why opt for SASS when bootstrap is LESS? Doesnt make sense.
Saturday, July 14th, 2012 10:01
Nice and pretty simple tutorial. What about those annoying comments in generated CSS file? I think it would be worth to notice that we can turn them off by uncommenting line_comments = false string in config.rb file which is in the project folder.
I personally prefer sass syntax, because of its conciseness. I’m feeling a bit ‘plain CSS-ing’ myself when writing in scss syntax.
Also a good practice is to use shorthands = and + instead of @mixin and @include.
If not, then it's time to learn how to:
You can trust 1stWebDesigner to help you become a better web designer!
- Jacob Cass | Just Creative
Just enter your name and email below and click Get Updates!
Roman Liutikov
Saturday, July 14th, 2012 10:01
Nice and pretty simple tutorial. What about those annoying comments in generated CSS file? I think it would be worth to notice that we can turn them off by uncommenting
line_comments = falsestring in config.rb file which is in the project folder.I personally prefer sass syntax, because of its conciseness. I’m feeling a bit ‘plain CSS-ing’ myself when writing in scss syntax.
Also a good practice is to use shorthands = and + instead of
@mixinand@include.Ranjith Kumar
Sunday, July 15th, 2012 00:24
Thanx Roman. = and + are a new addition to my repository :)
Thnx again for dropping by
Norma
Tuesday, July 17th, 2012 06:46
Why opt for SASS when bootstrap is LESS? Doesnt make sense.
L
Thursday, July 19th, 2012 06:44
Why there is no html5 elements like: nav and header?
Sudarshan
Monday, July 23rd, 2012 08:46
Great stuff!
Wanted to just drop by and appreciate you for helping more people adopt bootstrap.
ClickDesk is website designed using Twitter Bootstrap.
We blogged about it here – Why did ClickDesk choose Twitter Bootstrap? – http://blog.clickdesk.com/why-did-clickdesk-choose-twitter-bootstrap/