Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-06-2011, 09:50 PM   PM User | #1
187OnYoAss
New to the CF scene

 
Join Date: Nov 2011
Posts: 2
Thanks: 2
Thanked 0 Times in 0 Posts
187OnYoAss is an unknown quantity at this point
problem styling navbar with css and php current page indicator

Hey,

I can't wrap my head around this, not sure where to look to fix the problem
So if someone here can point me in the right direction it's greatly appreciated.

The "problem" is that in the menu bar, it indicates the current page but doing so, in every possible way I try to style the menu bar there is no space between the "current" tab and the tab next to it on the right.
also using a background image I can style every tab the same, except for the one that is marked as "current" by the php code. I must be overlooking something?


My html/php code:

Code:
<div id="navbar">
<ul>

<?php
   if ($thisPage=='home')
      {echo '<li class="here">Home';}
   else
      {echo '<li><a href="/">Home</a>';}?> </li>
      
<?php
   if ($thisPage=='News')
      {echo '<li class="here">News';}
   else
      {echo '<li><a href="/">News</a>';}?> </li>
      
<?php
   if ($thisPage=='Archives')
      {echo '<li class="here">Archives';}
   else
      {echo '<li><a href="/">Archives</a>';}?> </li>
      
<?php
   if ($thisPage=='Files')
      {echo '<li class="here">Files';}
   else
      {echo '<li><a href="/">Files</a>';}?> </li>

<?php
   if ($thisPage=='Contact')
      {echo '<li class="here">Contact';}
   else
      {echo '<li><a href="/">Contact</a>';}?> </li>
      
<?php
   if ($thisPage=='Chat')
      {echo '<li class="here">Chat';}
   else
      {echo '<li><a href="/">Chat</a>';}?> </li>
      
<?php
   if ($thisPage=='Forums')
      {echo '<li class="here">Forums';}
   else
      {echo '<li><a href="/">Forums</a>';}?> </li>
</ul>
</div>
The .css

Code:
#navbar {
    clear: both;
    font: Arial,Helvetica,sans-serif;
}
#navbar ul {
    list-style: none outside none;
    margin: 0;
    padding: 0;
    width: 1000px;
    text-align: center;
}

#navbar li, #navbar ul li.here {
    display: inline;
    margin: 0;
    padding: 0;
}

#navbar a, #navbar ul li.here {
    color: #FFFFFF;
    display: inline;
    padding: 10px 45px;
    width: 40px;
    text-decoration: none;
    text-align: center;
}
#navbar a:hover {
    background-color: red;
 
}
#navbar ul li.here {
    background-color: #859292;
    color: black;
    
}
Hope I stated my problem clearly enough, Thanks in advance

MJ
187OnYoAss is offline   Reply With Quote
Old 11-06-2011, 09:51 PM   PM User | #2
hawaiiwebdesign
New Coder

 
Join Date: Nov 2011
Location: Seattle, WA & Big Island, HI
Posts: 13
Thanks: 0
Thanked 3 Times in 3 Posts
hawaiiwebdesign is an unknown quantity at this point
.here{padding: 10px 45px;display:block}
hawaiiwebdesign is offline   Reply With Quote
Users who have thanked hawaiiwebdesign for this post:
187OnYoAss (11-06-2011)
Old 11-06-2011, 09:52 PM   PM User | #3
hawaiiwebdesign
New Coder

 
Join Date: Nov 2011
Location: Seattle, WA & Big Island, HI
Posts: 13
Thanks: 0
Thanked 3 Times in 3 Posts
hawaiiwebdesign is an unknown quantity at this point
FYI... it is bad practice to use nameID and elements... so ditch the ul li if you are just trying to style #navbar .here
hawaiiwebdesign is offline   Reply With Quote
Users who have thanked hawaiiwebdesign for this post:
187OnYoAss (11-06-2011)
Old 11-06-2011, 10:01 PM   PM User | #4
187OnYoAss
New to the CF scene

 
Join Date: Nov 2011
Posts: 2
Thanks: 2
Thanked 0 Times in 0 Posts
187OnYoAss is an unknown quantity at this point
Quote:
Originally Posted by hawaiiwebdesign View Post
FYI... it is bad practice to use nameID and elements... so ditch the ul li if you are just trying to style #navbar .here
Thanks, will sort that out!
187OnYoAss is offline   Reply With Quote
Old 11-06-2011, 11:39 PM   PM User | #5
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Quote:
Originally Posted by hawaiiwebdesign View Post
FYI... it is bad practice to use nameID and elements... so ditch the ul li if you are just trying to style #navbar .here
Quote:
Originally Posted by 187OnYoAss View Post
Thanks, will sort that out!
Good advice. Here's one explanation why - https://developer.mozilla.org/en/Writing_Efficient_CSS
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:44 AM.


Advertisement
Log in to turn off these ads.