Tabbed Vertical Menu
For this tutorial we are going to
make a box shape main with a vertical nav down the right hand size that changes
when hovered in pure CSS. Doc type is required to centre in internet explorer
So to start type the following HTML for the main and wrapper
<div id="wrapper">
<div id="main">
<h1>Tabbed Vertical Menu</h1>
<div class="line"></div>
Hover over each nav item to see it move.
</div>
and add the following CSS
body,h1,ul,li
{
margin: 0px;
padding: 0px;
color: #909090;
}
#wrapper
{
margin-left: auto;
margin-right: auto;
width: 602px;
margin-top: 50px;
}
#main
{
width: 380px;
height: 180px;
background-color: #f5f5f5;
border: 1px solid #e5e5e5;
padding: 10px;
font-family: arial;
font-size: 11pt;
float: left;
}
The first thing that we need to do
is remove defaults margins and paddings and set the main font colour. Next the
wrapper is created and we set a width of 602px and centre it using auto
margins(doc type needed for ie). The wrapper is also pushed down by 50 pixels.
The main part we apply some dimensions and colour with a border to give it its
shape and then set the font settings for the text we will have inside it later.
Float it left because the menu will be placed next to it.Padding is added to
push the content from the edge of the border.
Now to style the content inside the main with this
h1
{
font-family: arial;
font-size: 14pt;
font-weight: normal;
color: #0f8dce;
}
.line
{
background-color: #c8c8c8;
width: 90%;
height: 1px;
margin-bottom: 2.5px;
margin-top: 2.5px;
}
The h1 tag we use as our title and
remove bold and add font, colour and size to it. The line class is just line
that will separate the heading from the text. We set the margin to have a 90%
width so its only 90% width of the main and set the height to 1px and set the
colour of by using the background colour property. Margins are put it to make
some space and for this to work properly in ie you will need a doc type.
Now for the menu and the end of the wrapper
<div id="menu">
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li>Link 5</li>
</div>
</div>
and add the CSS
#menu
{
width: 200px;
height: 200px;
float: left;
}
li
{
list-style-type: none;
background-color: #f6f6f6;
border: 1px solid #dedede;
height: 20px;
width: 40px;
margin-top: 10px;
margin-bottom: 10px;
text-align: center;
font-size: 10pt;
}
li:hover
{
width: 100px;
height: 25px;
font-size: 12pt;
}
Lastly
comes the menu that sits on the right hand side of the main and changes when we
hover over each menu part. The menu div just wraps the list nicely and we use
to position it next to the main by floating left and giving it a shape. The li
tag is each list block and we apply colours, shape and font size. Margins are
to separate each of them so they are not next to each other.
The hover changes the shape and increases the
font size