Integrating Twitter’s Bootstrap Into Your Project
Twitter’s Bootstrap CSS framework has become very popular over the last year. So much so, that the default styles provided by Twitter are already considered cliche by many. While it is possible to override Bootstrap’s default look in your own CSS files, trying to overwrite all of Bootstrap’s undesired UI sugar quickly becomes an exercise in frustration.
There is a better way.
Bootstrap is written using LESS, a dynamic meta language which introduces variables, mixins, and functions and compiles down to CSS. The key to customizing Bootstrap is to start from these source files. In the rest of this article, I’ll show you what you need to do to get set up to work from these files.
Installing Node.js And The Required Modules
Bootstrap uses a few node.js modules to perform the compilation from LESS to CSS. Fortunately, installing node.js is very simple these days. Just head over to the main node.js site, download and run the installer for your system. Once the installation has been completed, open a new terminal or console window and type the following command:
node -v
If Node reports back with it’s version number, everything installed correctly.
The next step is to install the modules Bootstrap requires to compile. Node comes with a package manager (NPM) to ease the installation of 3rd party modules. Run the following command to install the required modules globally:
npm install recess jshint connect uglify-js -g
If everything installed correctly, your system is now setup to compile Bootstrap.
Installing Ruby and Watchr
This is an optional, but highly recommended, step. Bootstrap provides a makefile which uses the Ruby Watchr gem to monitor LESS files and automatically perform a compilation when a LESS file is changed on disk. This is very useful during development.
Instructions for installing Ruby are beyond the scope of this article, but the good folks behind the language have provided instructions for installing Ruby on various platforms.
Once your Ruby installation has been verified, run the following command to install the Watchr gem:
gem install watchr
Grab The Bootstrap Source Files
Bootstrap’s source files are hosted at github. You can either clone the repo using git, or download the zipped source. To clone the repo, open a terminal, navigate to the folder where you want to place the bootstrap files, and run the following command:
git clone https://github.com/twitter/bootstrap.git
Ideally, you should locate these files outside of your website’s public folder.
Grab A Makefile For Windows
Bootstrap only provides a makefile for Mac and Linux systems. If you’re on a Windows system, you’ll need to grab a make.bat file. Create this file in your bootstrap directory.
Testing Your Installation
Now that everything is in place, we can finally compile. Open a terminal, navigate to your Bootstrap folder, and enter the following command:
make
Twitter will compile everything and copy the newly compiled CSS files to the ./bootstrap/docs/assets/CSS/ folder.
Editing the Makefile
NOTE: These instructions are current as of Bootstrap v2.1.1.
The final step in this setup is to add an instruction in the makefile (or make.bat on Windows systems) to copy the compiled files to the CSS folder for your project. The following lines should be inserted right after the line which says: “Compiling documentation… ${CHECK} Done”. Be sure to set the path appropriately for your project.
For Mac or Linux systems:
MY_CSS_PATH = ../public/css
@cp ${BOOTSTRAP} ${MY_CSS_PATH}
@cp ${BOOTSTRAP_RESPONSIVE} ${MY_CSS_PATH}
@echo "Copying CSS to project... ${CHECK} Done"
For Windows:
SET MY_CSS_PATH = ..\public\css
<nul set /p =Copying CSS to project...
copy /Y %BOOTSTRAP% %MY_CSS_PATH%>nul
copy /Y %BOOTSTRAP_RESPONSIVE% %MY_CSS_PATH%>nul
echo %CHECK% Done.
Open a terminal and run the make command again. The compiled bootstrap files should be copied to your project’s folder.
If you followed the optional step of installing Ruby and Watchr, we can put make in “watch” mode. Enter the following command in a terminal:
make watch
As long as this process is running, make will monitor the LESS files for changes and automatically perform a compilation. This saves a bunch of time when you’re hacking away at the files.
Customize Bootstrap
Now that everything is setup, you can begin to customize Bootstrap to fit your site’s visual design style. A good place to start is the file variables.less. Much of Bootstrap’s look can be quickly tailored by changing values in this file.
Leave a comment
Recent Posts
- Gonzo’s Puppet Journey: Updating an Existing Package on Solaris 10 Using Puppet 2.7
- iOS Unit Testing With OCMock
- Why Stakeholders Need To Be Involved In Scrum
- NuGet Config File Transformation Causes Duplicate Entries On Update
- Load Testing with Locust on Windows
- Writing A Custom LINQ Provider With Re-linq
- AutoMapper Profile Organization
- Rails 3.2: A Nested-Form Demo Part 4: Switch to Targeting Computer!
- SharpRepository: Configuration
- Rails 3.2: A Nested-Form Demo, Part 3: We’re Starting Our Attack Run!
- Rails 3.2: A Nested-Form Demo, Part 2: Accelerate to Attack Speed!
- Rails 3.2: A Nested-Form Demo, Part 1: All Wings Report In!
- iOS Behind the Curve
- Distributed Transaction Coordinators, Port 135, and Firewalls – Oh My!
- SharpRepository: Getting Started
- Find Performance Problems Using JMeter, MySQL and Xdebug/Webgrind
- Taming Hot Key Context Shifting When Running A Windows VM In Virtualbox On OSX
- Integrating Twitter’s Bootstrap Into Your Project
- Mobile payments, tags and more using NFC
- Stress Pig
- Dear Client Services, What Works?
- What Would Steve Do?
- Still Using Fiddler to Test & Debug Your REST Services?
- Write-through and Generational Caching Make a Great Team
- Thinking Recursively
- Development Incentives, What’s the Payoff?
- How do you like them Apples?
- “Optional” Software Development Practices Series — Code Review
- Adding Images to Select Lists in MVC3
- “Optional” Software Development Practices Series
- You Get What You Pay For…
- Outsourcing Safety Tips
- Facebook IPO
- The Ballad of Tim Toady
- The Little Schemer
- Newsflash: Mom leaves tech job at 5p.m.
- Flashback!
- I <negative_emotion> Windows 8!
- Prefix vs. Postfix Increment and Decrement Operators in C++
- Corporate videos: viral boon or epic fail?
- Recruitin’ Time!
- Reference vs. pointer parameters in C++
- The IE8 "hover" Bug: The Most Awesome IE Bug Ever?
- When is perfect perfect enough?
- SOPA/PIPA: Anti-Censorship Protest or Techies Revenge?
- A Decade of Fairway
- Handling Session Timeout Gracefully
- Generating Software Diagrams
- The Audacity of Nope
- The Origins of Culture
- Scrum Overview in Prezi – not another boring slideshow
- Numbers don’t lie: LinkedIn Statistics
- What is your favorite software development tool?
- Best Practices for Selecting Onshore, Nearshore or Offshore Information Technology Outsourcing (ITO) Providers
- Sign of the Times
- Advantages and Risks of Offshoring, Nearshoring or Onshoring
- Does Outsourcing Mean Offshoring?
- Too little, too late?
- New Favorite Lunch Spot
- Why should I care about functions as first-class citizens?
- PHP Remote Debugging with XDebug and NetBeans
- Installing SubText with Web PI
- ROI Primer
- Learn Domain-Driven Design
- Learn Behavior-Driven Development
- Mario Kart Tournament
- F# in 90 Seconds
- Website Vulnerabilities
- Scrum Overview
- Language Club
- Top 12 Favorite Podcasts Ever…
- Fairway Dart Tournament
- Learn Lean Software Development and Kanban Systems
- Android – Eclipse Quick Start
- Learn Functional Programming
- Backup & Restore Strategy
- Smartphone Screens – Another Wireless Variable
- Wireless Application Market
- Head First AOP





