Welcome Guest ( Log In | Click here to Register a free account now! )
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.![]() ![]() |
Jun 16 2006, 08:57 AM
Post
#1
|
|
![]() Forum Regular ![]() ![]() ![]() Group: Members Posts: 245 Joined: 27-May 05 From: 127.0.0.1 Member No.: 21,516 |
How to make a Horizontal Navigation Bar with Link Rollover State using XHTML/CSS Guide Overview The purpose of this guide is to show how a horizontal navigation bar with a link "Roll Over" state can be achieved using XHTML/CSS without the use of tables, images, Javascript, or any other scripting manipulation. The following example validates according to W3C standards, and is compatible with all modern browsers. Instructions
Breaking down the CSS #navbar ul { margin: 0; padding: 5px; /* Set margin and padding for cross browser consistency. */ list-style-type: none; /* Needed to eliminate list item marker */ text-align: center; /* Centers navigation bar */ background-color: #000; /* Set as desired */ } #navbar ul li { display: inline; /* Needed to create horizontal effect */ } #navbar ul li a { text-decoration: none; /* The setting of "none" allows the link to not be underlined. This is up to user preference. */ padding: .2em 1em; /* Gives the link space inside it's individual block. */ color: #fff; /* Set as desired */ background-color: #000; /* Set as desired */ } #navbar ul li a:hover { color: #000; background-color: #fff; /* Both of these values create the "Rollover effect, Set as desired */ } This list as is can be modified to give many different visual results. Try changing the color values, add borders, or adjust padding and margin values. A look at the XHTML <body> <div id="navbar"> <ul> <li><a href="#">LinkHere</a></li> <li><a href="#">LinkHere</a></li> <li><a href="#">LinkHere</a></li> <li><a href="#">LinkHere</a></li> <li><a href="#">LinkHere</a></li> </ul> </div> </body> In place of the "#" symbols shown in the example, are where your links will go, and since each link is in it's own block element, the size of each link and it's rollover effect are determined automatically by the length of the text where "LinkHere" is shown. -------------------- When I'm right, I'm right....
And when I'm wrong, I could have been right.... So I'm still right, cause I could have been wrong. |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 5th September 2008 - 11:24 AM |