|
Geek: “fascinated by knowledge and imagination”
home |
about |
contact |
guestbook
|
Find Solutions > CSS
How to make the rollover effect on the sidebar navigation?
It's all made with simple html, and some css (stylesheet) rules.
the html
Can it really be that simple??!!
Where's the table code, and the javascript?
It's all done with the magic of stylesheet language.
the css
(All the below blocks of css code go together in the
stylesheet, but i have separated them
to put in explanations.)
-
First we tell that "
pageNav" div
to have a certain width, and to float to the left.
This makes the grey column on the left.
And we give our column a font-size, padding, and background color:
div#pageNav {
float: left;
width: 105px;
font-size: 90%;
padding: 0;
background-color: #eeeeee;
}
-
Next: the list. We don't really want it look
like a list! So in the stylesheet we take away
all the bullets, margins, and padding, and then
make the big grey line at the top of the list block.
div#pageNav ul {
list-style: none;
margin: 0;
padding: 0;
border-top: 4px solid #ccc;
}
div#pageNav ul li {
margin: 0;
}
-
Now here's what makes it pretty.
We tell the links ('a' tags) to be blocks
instead of inline, and we take away the underline
with
text-decoration: none;
Then we can give them a padding, border, etc,
... which makes them look like table cells.
div#pageNav a:link, div#pageNav a:visited, div#pageNav {
display: block;
color: #000000;
text-decoration: none;
font-size: 110%;
padding: 3px 0px 3px 10px;
border-top: 1px solid #ccc;
/* here's an "invisible line" to keep the menu from "jumping"
on hover below */
border-bottom: 1px solid #eee;
}
-
And then we tell the links to go red (
#cc0000)
when the mouse pointer hovers over them:
div#pageNav a:hover {
color: #cc0000;
text-decoration: none;
border-top: 1px solid #cc0000;
border-bottom: 1px solid #cc0000;
}
Yes, there is more ...
-
To see the html code for the entire sidebar navigation,
"View source" in your browser, and scroll down to the
<div id="pageNav"> section.
-
To see the rest of the stylesheet, again in "View source",
look in the
<head> part of the page, and find
the line that shows the location of the stylesheet.
(It will start with
<link rel="stylesheet" ...)
The path in the href part of that line,
can be pasted into your browser address bar after
the domain name, and you will see the stylesheet itself.
[an error occurred while processing this directive]
|