TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-09-2009, 02:53 AM   #1 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default Padding without moving border?

Hey,

I have a navigation using LIs. I added a border to the right to simulate a spacer for each link. What I'm trying to do is add padding to the top to bring the text down some becasue it's too high. But when I do that, the padding also moves the border. Is there a way around this?

HTML
Code:
<div id="nav">
    <ul>
      <li><a href="#">Stories</a></li>
      <li><a href="#">Blogs</a></li>
      <li><a href="#">Forums</a></li>
      <li><a href="#">Tournament</a></li>
      <li><a href="#">Podcasts</a></li>
    </ul>
  </div>
CSS
Code:
#nav ul
{
  float: left;
  width: 324px;
  margin: 21px 0px 0px 0px;
  padding: 0px;
  color: #FFFFFF;
}

#nav ul li { display: inline; }

#nav ul li a
{
  float: left;
  height: 30px;
  padding: 0px 8px 0px 8px;
  font-weight: bold;
  color: #FFFFFF;
  text-decoration: none;
  border-right: 1px solid #670000;
  background: url('../images/nav_bg.jpg') repeat-x;
}

#nav ul li a:hover
{
  color: #670000;
  background: url('../images/nav_bg_o.jpg') repeat-x;
}
I also want to add an active LI so I added

Code:
#featuresNav ul li .active
{
  color: #000000;
  background: #FFFFFF;
}
and I did <li class="active"><a href="#">blah</a></li> but it doesn't work.

Basically I just want the background and font color to change if I set the LI element to "active".

thanks :)
9three is offline  
Reply With Quote
Old 05-09-2009, 04:27 AM   #2 (permalink)
The Wanderer
 
Join Date: Jan 2008
Posts: 24
Thanks: 13
sidisinsane is on a distinguished road
Default

Increase the line-height on the a-element instead of using padding-top. Besides that, there's a mistake in your active-state declaration. Remove the space between the li-element and the class, so that it looks like this: #featuresNav ul li.active
sidisinsane is offline  
Reply With Quote
Old 05-09-2009, 02:47 PM   #3 (permalink)
The Addict
 
CoryMathews's Avatar
 
Join Date: Nov 2007
Location: USA
Posts: 256
Thanks: 7
CoryMathews is on a distinguished road
Default

#featuresNav ul li .active
to
#featuresNav ul li.active

is not always a mistake. The second states I want the li that has a class of active the first states that you want an li that has or contains the class active. So if you were to put the class on the li tag you would want the li.active if you were going to put it on the a tag you would want the li .active.

Second line height is one of those things you try to avoid as it is not 100% implemented in all the browsers. So you may get funky results when its combined with different things.
CoryMathews is offline  
Reply With Quote
Old 05-09-2009, 03:54 PM   #4 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default

thanks guys but its not working.

I did:

Code:
#nav ul li.active
{
  color: #000000;
  background: #FFFFFF;
}
Code:
<div id="nav">
    <ul>
      <li class="active"><a href="#">Stories</a></li>
      <li><a href="#">Blogs</a></li>
      <li><a href="#">Forums</a></li>
      <li><a href="#">Tournament</a></li>
      <li><a href="#">Podcasts</a></li>
    </ul>
  </div>
nothing happens though. I removed the space like you had said to.
9three is offline  
Reply With Quote
Old 05-10-2009, 04:39 AM   #5 (permalink)
WebDev'n Beer Drnkn' Fool
 
stewart's Avatar
 
Join Date: Dec 2007
Location: Denver, CO
Posts: 59
Thanks: 2
stewart is on a distinguished road
Default

It's because the "weight" is not greater... or it isn't defined more specifically ? For lack of better description.
Try this :

Code:
div#nav ul li.active
{
  color: #000000;
  background: #FFFFFF;
}
Notice the div in front of the id selector. This gives this declaration more "weight".

This SHOULD work, and just a note, you can use ul as the "nav" container itself, no need for an extra wrapping div :)

Edit :
Re-read your original post, might have to add an "a" at the end of that ^
__________________
stewart::howe
Web Developer & Programmer
CelerMedia.Com | iAmStewart.com | CelerLabs.com
Send a message via ICQ to stewart Send a message via AIM to stewart Send a message via MSN to stewart Send a message via Yahoo to stewart
stewart is offline  
Reply With Quote
Old 05-13-2009, 02:00 PM   #6 (permalink)
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default

thanks it works. What if I wanted to add padding to the top without the border to the right moving? I tried doing a couple of different things but it doesn't seem to work.

edit:

nvm I just saw the 2nd post. works :)
9three is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
why does this border show when i click on a image button sarmenhb XHTML, HTML, CSS 2 12-02-2008 07:49 PM
CSS Padding / Textarea problems Alan @ CIT XHTML, HTML, CSS 5 03-09-2008 07:58 PM
Menu Display Problem in IE6+ obolus XHTML, HTML, CSS 14 03-01-2008 07:57 PM


All times are GMT. The time now is 07:43 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design