Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Inline navigation

Featured Replies

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>

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>

  • 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.

  • Author

try changing this

 

.nav li a:hover, .nav li.selected a {}

to

.nav li a:hover, .selected {}

 

Not working, wonder why.

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;
}

  • 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.

  • 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?

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.

  • 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!

post-12073-126692139757_thumb.png

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;
}

  • 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 :)

  • 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.

post-12073-126692291338_thumb.png

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.

  • 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.