Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Using tabs and pills for navigation

From: Up and Running with Bootstrap 3

Video: Using tabs and pills for navigation

Well, we've been working away on Bootstrap here and we've gone through several chapters of building individual webpages. But did anyone notice that there was something missing that was kind of obvious? Like I don't know, a navigation bar. We built all these great pages for this website but they have no way of linking to each other. So it's high time that we talked about navigation bars and how we could actually link together all these pages into a coherent website. So I am taking a look at file 04_02, which comes from your exercise files folder. Go ahead and copy this file into your Bootstrap folder.

Using tabs and pills for navigation

Well, we've been working away on Bootstrap here and we've gone through several chapters of building individual webpages. But did anyone notice that there was something missing that was kind of obvious? Like I don't know, a navigation bar. We built all these great pages for this website but they have no way of linking to each other. So it's high time that we talked about navigation bars and how we could actually link together all these pages into a coherent website. So I am taking a look at file 04_02, which comes from your exercise files folder. Go ahead and copy this file into your Bootstrap folder.

And then open it on up in your browser, and you should see this. And so what you see here, is, I've got two navigation items going on here. Up at the very top left of the page above the logo. I have a bulleted list. Ultimately of course that should probably become some kind of horizontally oriented navigation for this website. And then underneath the logo I have another set of navigation. This is probably some kind of sub navigation for this particular part of the website. And, this might lead to other pages, or it could lead to other sections on the same page.

So, I need to style both of these things, because they really don't look all that great just as they are, and so, I would like to walk through that now. And so we've got two bars that we need to style. So, I'm going to start by going to Sublime Text, here, and I'm going to show you the mark up that I've used to put these navigation bars in place. So, starting here, now, around line 16, is the top navigation bar for the website. And I've marked this up with a nav with a class of row. So the nav tab once again one of the HTML five semantic tags indicating that this is a major piece of navigation on the website.

And here's an un-ordered list because ultimately, it really doesn't matter what order these links are in. It matters to marketing of course, but one page isn't related to the other. In the case of the breadcrumb, we needed to mark this up as an ordered list because it does very much matter that the order that those links are in. And then, further on down the page here, if we go down to line 92. This is it on the side here. This is our sub navigation for the website. And notice that this is not in a navigation tab.

Why would I not put this in a navigation tab? Because the specs for the navtab indicates they should go in place where there is major navigation for the website. Where, if this were missing, it would really be a kind of tragedy, it couldn't navigate the website. So my determination was that this was not major navigation for the website, so I did not use a navtab in this particular place. If you feel this is major navigation for your website, by all means you can certainly go ahead and use that nav tag. These symantic questions aren't not necessarily all that cut and dry.

So, that is why there's no nav tag here. So, what we're going to do to start with, just to get a very basic nav bar. Is we're going to add a class. And that class is right here on this ul. We'll add a class of nav. This is on line 93. And we'll also add that class of nav all the way up here on line 17. Class of nav. And if you just go ahead and save your page and refresh it here in you browser. You'll see that, already, something has happened.

And, in fact, these are styled exactly the same way. Sort of a block level kind of navigation. When you hover over it, you get this grey bar, that is as wide as its containing element. That's very very wide up here on the top. And not as wide down here in the left column. So that is the most basic navigation bar. Just adding that class of nav to the ul. Then, we can continue to add classes here in order to get additional styling. So, back here on line 17 I can add a class of nav, hyphen, tabs.

So this is going to orient things as tabs on the page. In order to make this work. To have tabs that really look like tabs. I need to also indicate what page I'm currently on. Well, I'm on the services page. So, to the li, I will add a class of active. Indicating, that this is where I am in the hierarchy. So, if you go ahead and save this and if you refresh this in your browser, you'll see that we now have a tab, for the page that we are currently on, which is services. If this other navigation was working, which it's not hooked up to anything, so it doesn't, as we switch to other pages here on the site, then the active state should move and that would change the shape of this tab, to fit other places here on the page.

You can add, nav of tabs, down here. On line 93 you could add a nav hyphen tabs here also. That off course is going to make your navigation go horizontally across the page. But if you add a nav hyphen stacked, this is going to stack your navigation and keep it vertical, even though you are calling for tabs. So, if you save this, and you take a look at this inside of your browser. These are now considered to be tabs and because I didn't specify which one was active, these don't really look all that tabby.

So, let me indicate which one is an active one. So class equals active here on this li. And now, if I refresh the page, then I do have a tab here, which indicates the Vaccinations is active. Although I can navigate to these other pages. I don't think the tabs in a stacked format works really well, but it's supported. And you can certainly set things up this way. What actually works better in this orientation is the pill format. Here again on line 93, if you change nav tabs to nav pills, pills, and save and refresh your webpage you'll see that now we have these lovely pills over here on the left side of the screen.

With the active page indicated by the big blue pill. And of course you probably want to change the colors here at some point in time to make this work better with the color scheme for your website. Likewise we can add a class of pills up here at the top of the page. So scrollall the way back on up. Up here to the top on line 17. Instead of nav tabs we can change this to nav pills. Save that. And refresh our web page. And now I have these lovely pills that grow across the top of the page. And as my very final trick, you might want to stretch this navigation out to stretch the full width of the page.

And that's completely possible now with Bootstrap 3. You're going to add to nav pills. Nav-justified. And that will justify the navigation across its containing element, which in this case it's 12 columns wide. So, it's going to go all the way across. So, there we go. Now, we have navigation that stretches fully across the page. Designers might not be happy. It looks like the word home here isn't quite aligned with things, but when you mouse over it you'll see that if the left edge of that pill is in fact aligned with the left column there. So, just with a handful of classes, including nav, nav tabs, nav pills, nav justified.

And now stacked so those five classes and various combinations, we're able to change the look of these navigation bars here on our website in just a few clicks.

Show transcript

This video is part of

Image for Up and Running with Bootstrap 3
Up and Running with Bootstrap 3

37 video lessons · 23026 viewers

Jen Kramer
Author

 
Expand all | Collapse all
  1. 5m 25s
    1. Welcome
      58s
    2. Using the exercise files
      1m 19s
    3. Installing Sublime Text 2
      3m 8s
  2. 29m 0s
    1. What is Bootstrap?
      8m 1s
    2. Downloading and unzipping Bootstrap 3
      4m 31s
    3. Examining Bootstrap file structure
      4m 34s
    4. Adding CSS to a Bootstrap HTML file
      4m 35s
    5. Adding JavaScript to a Bootstrap HTML file
      7m 19s
  3. 44m 38s
    1. Exploring Bootstrap's grid system
      9m 10s
    2. Creating new rows and cells
      14m 5s
    3. Adjusting column widths using offset
      5m 2s
    4. Changing column order using push and pull
      5m 34s
    5. Nesting columns
      3m 43s
    6. Creating a JumboTron-style layout
      3m 41s
    7. Challenge: Working with grids
      1m 31s
    8. Solution: Working with grids
      1m 52s
  4. 53m 34s
    1. Exploring basic typography: The small and blockquote tags
      4m 29s
    2. Exploring Bootstrap's responsive classes including .hidden and .visible
      4m 44s
    3. Styling buttons using btn classes
      4m 43s
    4. Styling images with responsiveness and decorative touches
      5m 22s
    5. Incorporating Bootstrap 3 glyph icons
      3m 28s
    6. Creating a thumbnail gallery
      6m 2s
    7. Styling tabular data
      5m 3s
    8. Overriding core CSS with custom styles
      12m 53s
    9. Challenge: Styling panels and callouts
      2m 17s
    10. Solution: Styling panels and callouts
      4m 33s
  5. 27m 41s
    1. Implementing location breadcrumbs
      6m 38s
    2. Using tabs and pills for navigation
      6m 58s
    3. Developing a responsive navigation bar
      9m 9s
    4. Challenge: Modify the "pancake" button
      1m 3s
    5. Solution: Modify the "pancake" button
      3m 53s
  6. 37m 45s
    1. Implementing dropdowns within a navigation bar
      5m 5s
    2. Tabbing within the same page
      15m 45s
    3. Accordion panels with collapse functionality
      11m 37s
    4. Challenge: Tooltips
      1m 59s
    5. Solution: Tooltips
      3m 19s
  7. 3m 0s
    1. Next steps towards advanced Bootstrap
      3m 0s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Up and Running with Bootstrap 3.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.