The elements in a list can all be changed an positioned using CSS. We have full control over how they display.
One of the most common things you will want to do with a list is to remove the bullet points. We do this with CSS like so:
ul {
list-style: none;
}
When you think about it, a navigation is essentially a list of links. In this section we will create a horizontal navigation.
<nav>
<ul>
<li>
<a href="http://www.google.com"> Google </a>
</li>
<li>
<a href="http://www.yahoo.com"> Yahoo </a>
</li>
<li>
<a href="http://www.bing.com"> Bing </a>
</li>
</ul>
</nav>
With a little CSS we can style this as a horizontal nav
nav ul,
nav li {
list-style: none;
margin: 0;
padding: 0;
}
nav li {
display: inline-block;
padding: 0 10px;
}
This looks something a little like this:
%style nav.horizontal_demo { border:1px solid black; padding:10px; } nav.horizontal_demo ul, nav.horizontal_demo li { list-style:none; margin:0; padding:0; } nav.horizontal_demo li { display:inline-block; padding:0 10px; } %nav.horizontal_demo %ul %li %a{:href => ”http://www.google.com”} Google %li %a{:href => ”http://www.yahoo.com”} Yahoo %li %a{:href => ”http://www.bing.com”} Bing
We can create vertical navigation from an unordered list
A vertical navigation!
Add a sublist and style the elements in it a little bit smaller without a background.
We’re going to create a horizontal navigation of your own with a few enhancements.
Either recreate a horizontal navigation something like this one:
%img{ src: ‘/images/smashing_nav.png’, style: ‘width:100%’ }
or create tabs something like these:
%img{ src: ‘/images/streetbank_nav_narrow.png’, style: ‘width:100%’ }
%aside