February 22, 201016 yr Hi guys, I'm using the "<ul><li></li></ul>" method for inline navigation menu. I want to have a rounded border for a current selected page. Don't mind helping me check what's wrong with me code? CSS .top-menu { width: 1260px; margin: 0 auto; } .nav { float: left; display: block; margin-top: 20px; } .nav li { display:inline; } .nav li a { color: #fffff; padding: 0px 25px 0px 0px; display: block; float: left; font-size: 16px; } .nav li a:hover, .nav li a.selected { color: #5e5e5e; text-decoration: none; -moz-border-radius: 10px; } HTML <div class="top-menu"> <ul class="nav"> <li><a class="selected" href="home.html">Home</a></li> <li><a href="about.html">About Me</a></li> <li><a href="works.html">Works</a></li> <li><a href="contact.html">Contact</a></li> </ul> </div>
February 22, 201016 yr Move your selected class to your li element. Change the css to match. .nav li a:hover, .nav li.selected a { color: #5e5e5e; text-decoration: none; -moz-border-radius: 10px; } <div class="top-menu"> <ul class="nav"> <li class="selected"><a href="home.html">Home</a></li> <li><a href="about.html">About Me</a></li> <li><a href="works.html">Works</a></li> <li><a href="contact.html">Contact</a></li> </ul> </div>
February 22, 201016 yr Author My full CSS is now this, after making changes as what you said: body { font-family: Helvetica Neue, Helvetica, Arial; color: #ffffff; font-size: 14px; background: #1f1f1f; } a:link, a:active, a:visited { text-decoration: none; color: #ffffff; } a:hover { text-decoration: underline; color: #ffffff; } .top-menu { width: 1260px; margin: 0 auto; } /* Navigation */ .nav { float: left; display: block; margin-top: 20px; } .nav li { display:inline; } .nav li a { color: #fffff; padding: 0px 25px 0px 0px; display: block; float: left; font-size: 16px; } .nav li a:hover, .nav li.selected a { color: #5e5e5e; text-decoration: none; -moz-border-radius: 10px; } #footer { clear: both; font-size: 12px; text-align: center; color: #5e5e5e; } It still didn't work for me.
February 22, 201016 yr try changing this .nav li a:hover, .nav li.selected a {} to .nav li a:hover, .selected {}
February 23, 201016 yr Author try changing this .nav li a:hover, .nav li.selected a {} to .nav li a:hover, .selected {} Not working, wonder why.
February 23, 201016 yr How could you have border radius, without having a border, or even a background color? Your code should be: .nav li a:hover, .nav li.selected a { background: #ff0000; color: #5e5e5e; text-decoration: none; border: 2px solid #000000; -moz-border-radius: 10px; }
February 23, 201016 yr Author How could you have border radius, without having a border, or even a background color? Your code should be: .nav li a:hover, .nav li.selected a { background: #ff0000; color: #5e5e5e; text-decoration: none; border: 2px solid #000000; -moz-border-radius: 10px; } Hmmm, thanks for pointing out to me. I'll figure some things out before I check back. Thanks.
February 23, 201016 yr Author So, my question was to make sure that the "selected" class will show the rounded border, with empek's post, the border only shows when I hover over. Even after I altered part of the code to this: .nav li a:hover, .nav li.selected a { color: #5e5e5e; text-decoration: none; } .nav li a.selected { background: #1f1f1f; border: 1px solid #ffffff; -moz-border-radius: 10px; } It didn't work. Anyone can point to me what's wrong?
February 23, 201016 yr So, my question was to make sure that the "selected" class will show the rounded border, with empek's post, the border only shows when I hover over. Even after I altered part of the code to this: .nav li a:hover, .nav li.selected a { color: #5e5e5e; text-decoration: none; } .nav li a.selected { background: #1f1f1f; border: 1px solid #ffffff; -moz-border-radius: 10px; } It didn't work. Anyone can point to me what's wrong? Change it to this (if the class is assigned to the <li>): .nav li a:hover, .nav li.selected a { color: #5e5e5e; text-decoration: none; } .nav li.selected { background: #1f1f1f; border: 1px solid #ffffff; -moz-border-radius: 10px; } If the class is assigned to the anchor, change it to this: .nav li a:hover, .nav li a.selected { color: #5e5e5e; text-decoration: none; } .nav li a.selected { background: #1f1f1f; border: 1px solid #ffffff; -moz-border-radius: 10px; } Hope that clears up some things.
February 23, 201016 yr Author Alright, thanks empek! Btw, I have another question. So my new CSS will now be: body { font-family: Helvetica Neue, Helvetica, Arial; color: #ffffff; font-size: 14px; background: #1f1f1f; } a:link, a:active, a:visited { text-decoration: none; color: #ffffff; } a:hover { text-decoration: underline; color: #ffffff; } .top-menu { width: 1260px; margin: 0 auto; } /* Navigation */ .nav { float: left; display: block; margin-top: 20px; } .nav li { display:inline; } .nav li a { color: #fffff; padding: 0px 25px 0px 0px; display: block; float: left; font-size: 16px; } .nav li a:hover, .nav li a.selected { color: #5e5e5e; text-decoration: none; } .nav li a.selected { background: transparent; border: 1px solid #ffffff; -moz-border-radius: 10px; } #footer { clear: both; font-size: 12px; text-align: center; color: #5e5e5e; } As you can see below, the image, my Home has a huge space at the right. Can someone guide me on aligning the Home and the rest to the center of the border? Thanks a lot!
February 23, 201016 yr Change code to this: body { font-family: Helvetica Neue, Helvetica, Arial; color: #ffffff; font-size: 14px; background: #1f1f1f; } a:link, a:active, a:visited { text-decoration: none; color: #ffffff; } a:hover { text-decoration: underline; color: #ffffff; } .top-menu { width: 1260px; margin: 0 auto; } /* Navigation */ .nav { float: left; display: block; margin-top: 20px; } .nav li { display:inline; } .nav li a { color: #fffff; padding: 0px 10px; margin-right: 25px; display: block; float: left; font-size: 16px; text-align: center; } .nav li a:hover, .nav li a.selected { color: #5e5e5e; text-decoration: none; } .nav li a.selected { background: transparent; border: 1px solid #ffffff; -moz-border-radius: 10px; } #footer { clear: both; font-size: 12px; text-align: center; color: #5e5e5e; }
February 23, 201016 yr Author Wow, Empek! Thanks a lot! Seriously, I'm still confused by how margin, float & padding works, so does my classes. Thanks for solving my problems
February 23, 201016 yr Author Sorry, once again, guys. Is it just me, or can you guys see the "lines" at the edge of the border? I've changed my border color to that of my background, and it's still not that great as I want it to: I wanted to make the border something just like the Learn More from http://openatrium.com/, which is beautiful. Right now, by looking at mine, it isn't that beautiful at all, more of ugly, right? Sorry if I'm bothering you guys.
February 23, 201016 yr This great article by Chris Coyier should help you understand some of the differences. As for the white line, it depends on the operating system, as well as browser client/version. To achieve the Open Atrium look, try adding more padding, and reducing the border radius to ~5px.
February 23, 201016 yr Author This great article by Chris Coyier should help you understand some of the differences. As for the white line, it depends on the operating system, as well as browser client/version. To achieve the Open Atrium look, try adding more padding, and reducing the border radius to ~5px. Thanks a lot! You've helped me. +1!
Create an account or sign in to comment