4 years ago1,000+ Views
In this lesson, I will teach you how to start building your one-page website with a CSS framework called Bootstrap. A CSS framework is a skeleton, or building block that works as a template when starting your site. Bootstrap is built by Twitter and has many features including a responsive design that allows your website to fit in any screen size, even mobile devices. I am showing you a quick way to build a page, but I highly encourage you to research more about Bootstrap and get a basic understanding of what you are downloading and using. WHAT YOU NEED: - Basic understanding of HTML + CSS - Bootstrap Framework - Text Editor (Notepad++) Follow the slideshow for helpful screen captures STEP 1: Download Bootstrap at and extract zip file STEP 2: Create a folder for your website. I am calling mine "demo site". Copy the extracted files into this new folder. You should have a 'css', 'js', and 'fonts' folder. STEP 3: Create and save your index.html in the main folder. In order to use the boostrap framework you need to link the CSS files as well as the Javascript files. In this lesson, you don't need to know Javascript. The basic template of your html website will be as follows: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Demo One Page Site</title> <!-- Link Bootstrap CSS Stylesheet --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src=""></script> <script src=""></script> <![endif]--> </head> <body> <!-- You will put code here--> <!-- KEEP THIS AT BOTTOM --> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src=""></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="js/bootstrap.min.js"></script> </body> </html> STEP 4: Adding structure So, for the sake of this example, I will have 4 sections on my index.html: Navigation, About, Portfolio, and Contact. Bootstrap has a grid structure implemented already, so all we need to do is structure it in the HTML. (Refer to Note: All of this will go inside the body tag NAVIGATION <nav class="navbar navbar-default navbar-static-top" role="navigation"> <div class="container"> <ul class="nav navbar-nav"> <li><a href="#about">About</a></li> <li><a href="#portfolio">Portfolio</a></li> <li><a href="#contact">Contact</a></li> </ul> </div> </nav> Notice that the links are simply hashtags, that is because you will be making anchors (links that lead to a specific section on the same page) ABOUT SECTION Just so you know, I'm not following any specific guidline here and I am just making this page as we go. I want to have two columns for my about section: one for a picture, and another with space to write about myself. I do this by making a <div class="container> </div> tag and then inside that tag making a row tag with column tags inside. I made a placeholder about image and put it inside a folder that I called "images". Therefore, when linking the image, I linked it to "images/about.jpg". You can use a sample image for the mean time. So, first put this code inside the body section <div class="container> </div> Then inside that tag, paste this code: <!-- ABOUT SECTION --> <div class="row"> <div class="col-md-4"> <img src="images/about.jpg" align="center" /> </div> <div class="col-md-8"> <a name="about"></a> <h1>About</h1> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. </p> </div> </div> PORTFOLIO SECTION Bootstrap has a thumbnail class that you can use to style a portfolio grid of images. I created another placeholder image and put it in the same "images" folder. <!-- PORTFOLIO SECTION --> <div class="row"> <a name="portfolio"></a> <h1>Portfolio</h1> </div> <div class="row"> <div class="col-xs-6 col-md-3"> <a href="#" class="thumbnail"><img src="images/placeholder.jpg" alt="..."></a> </div> <div class="col-xs-6 col-md-3"> <a href="#" class="thumbnail"><img src="images/placeholder.jpg" alt="..."></a> </div> <div class="col-xs-6 col-md-3"> <a href="#" class="thumbnail"><img src="images/placeholder.jpg" alt="..."></a> </div> <div class="col-xs-6 col-md-3"> <a href="#" class="thumbnail"><img src="images/placeholder.jpg" alt="..."></a> </div> </div> CONTACT SECTION Bootstrap also has form styling, so we will create a dummy form here for you to use in the contact section: <!-- CONTACT SECTION --> <div class="row"> <a name="contact"></a> <h1>Contact</h1> <div class="col-md-4"> <form role="form"> <div class="form-group"> <label for="exampleInputEmail1">Email address</label> <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email"> </div> <div class="form-group"> <label for="yourmessage">Message</label> <input type="textbox" class="form-control" id="yourmessage" placeholder="Your Message"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> </div> </div> Notice that the form and portfolio section are in rows and then inside the rows there are columns. I hope the long post didn't intimidate you. I tried to simplify it as much as possible. I hope the slideshow is helpful. In the last part of this series I will teach you how to upload and host this one-page website.