Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Why isn't this working?

Posted on 2004-08-14
10
Medium Priority
?
259 Views
Last Modified: 2012-05-05
I am having an issue where an LI tag isn't applying its class for some reason.


Here is the page:

      <div class="leftMenuBubble">        
        <div class="leftMenu">
          <ul>
            <li id="bgTop"><a href="#"><div class="MC">New Menu Item One</div></a></li>
            <li id="bgNormal"><a href="#"><div class="MC">New Menu Item Two</div></a></li>
            <li id="bgNormal"><a href="#"><div class="MC">New Menu Item Three</div></a></li>
            <li id="bgNormal"><a href="#"><div class="MC">New Menu Item Four</div></a></li>
            <li id="bgNormal"><a href="#"><div class="MC">And So on..</div></a></li>
            <li id="bgSelected"><a href="#"><div class="MC">Selected Item!</div></a></li>
          </ul>
          <div class="leftMenuYellow">
            This is where the sub information will go for the menu item that has been selected.
            I still need to make it so that there are borders here, right now there aren't.. shouldn't be hard.
          </div>
          <ul>
            <li id="bgNormal"><a href="#"><div class="MC">And So on..</div></a></li>
            <li id="bgNormal"><a href="#"><div class="MC">Last One</div></a></li>
          </ul>
        </div>
      </div>  

And here is the CSS;

  .leftMenuBubble {  
    width: 100%;  
    background-color: #005F85;  
    margin: 0px auto;
    padding: 0px;
    font-family: verdana;
    font-size: 12px;
    font-weight: bold;
    }
 
  .leftMenu ul {
    margin:0px auto;
    padding:0px auto;
    list-style:none;
    }
 
  .leftMenu a {    
    height: 20px;
    color: #FFF;
    text-decoration: none;
    display:block;
    text-indent: 6px;
    }    
  .leftMenu #bgNormal a {
    background: url("images/leftMenuButtonRight.jpg") no-repeat right top;    
    }
  .leftMenu #bgTop a {
    background: url("images/leftMenuButtonRightA.jpg") no-repeat right top;    
    }    
  .leftMenu #bgSelected a {
    background: url("images/leftMenuButtonRightS.jpg") no-repeat right top;    
    }    
   
  .leftMenu li {
    padding: 0px auto;
    margin: 0px auto;
    height 20px;
    background: url("images/leftMenuButtonLeft.jpg") no-repeat left top;
    }
  .leftMenu #bgNormal li {
    background: url("images/leftMenuButtonLeft.jpg") no-repeat left top;
    }  
  .leftMenu #bgTop li {
    background: url("images/leftMenuButtonLeft.jpg") no-repeat left top;
    }      
  .leftMenu #bgSelected li {
    background: url("images/leftMenuButtonLeftS.jpg") no-repeat left top;    
    }
   
  .MC {
    margin-top:3px;
    }


The line that I am specifically having issue with is this one;

            <li id="bgSelected"><a href="#"><div class="MC">Selected Item!</div></a></li>

Declairing a different ID in the LI works for the anchor (a) tag perfectly, but not for the LI itself.

The Anchor tag has the correct graphic with this;

            <li id="bgSelected"><a href="#"><div class="MC">Selected Item!</div></a></li>
           
but the LI itself isn't taking on the attributes of this;

  .leftMenu #bgSelected li {
    background: url("images/leftMenuButtonLeftS.jpg") no-repeat left top;    
    }
   
Why does this work;
  .leftMenu #bgSelected a {
    background: url("images/leftMenuButtonRightS.jpg") no-repeat right top;    
    }    
but the LI doesn't?    
   

You can see this page in full here:  http://www.rsow.com/design9/

0
Comment
Question by:Palamedes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 31

Expert Comment

by:seanpowell
ID: 11801923
A few issues here...

1.  id="bgNormal"

id's are unique - only one per page.

2. <li id="bgSelected"><a href="#"><div class="MC">Selected Item!</div></a></li>

The extra div tag is unnecessary and illegal syntax.

I'll post a corrected version for you...
0
 
LVL 4

Author Comment

by:Palamedes
ID: 11801943
I'm new to CSS so thanks..

SO I have to make all the ID="bgNormal"s a class.. why not just make everything a class then?

A DIV within a the LI is illegal syntax?  
0
 
LVL 31

Accepted Solution

by:
seanpowell earned 500 total points
ID: 11801982
Try this:


/* Left Menu Classes */
#leftMenuBubble
{  
      width: 100%;
      background-color: #005F85;
      margin: 0;
      padding: 0;
      font: bold 12px verdana, sans-serif;
}
 
#leftMenu ul
{
      margin:0;
      padding:0;
      list-style:none;
}

#leftMenu li
{
      background: url("images/leftMenuButtonLeft.jpg") no-repeat left top;
      padding:0;
      margin:0;
}
 
#leftMenu a
{
      padding: 3px 0 0 0;
      height: 17px;
      color: #FFF;
      text-decoration: none;
      display:block;
      text-indent: 6px;
}    

#leftMenu li.bgNormal a
{
      background: url("images/leftMenuButtonRight.jpg") no-repeat right top;    
}

#leftMenu li#bgTop a
{
      background: url("images/leftMenuButtonRightA.jpg") no-repeat right top;    
}  

 
#leftMenu li#bgSelected
{
      background: url("images/leftMenuButtonLeftS.jpg") no-repeat left top;    
}

#leftMenu li#bgSelected a
{
      background: url("images/leftMenuButtonRightS.jpg") no-repeat right top;    
}


      <div id="leftMenuBubble">  
        <div class="leftMenuBubbleTopBg"><div class="leftMenuBubbleTopRight"></div></div>      
        <div id="leftMenu">
          <ul>
            <li id="bgTop"><a href="#">New Menu Item One</a></li>
            <li class="bgNormal"><a href="#">New Menu Item Two</a></li>
            <li class="bgNormal"><a href="#">New Menu Item Three</a></li>
            <li class="bgNormal"><a href="#">New Menu Item Four</a></li>
            <li class="bgNormal"><a href="#">And So on..</a></li>
            <li id="bgSelected"><a href="#">Selected Item!</a></li>
            <li class="bgNormal"><a href="#">And So on..</a></li>
            <li class="bgNormal"><a href="#">Last One</a></li>
          </ul>
        </div>
      </div>  
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11801989
If I understand what you are trying to do, then these declarations are incorrect:

.leftMenu #bgNormal li {
that says tag li within an ancestor with id bgnormal within a container of class leftmenu.

I think you want .leftMenu li#bgNormal which says li tags with an id of bgNormal inside a container of class leftmenu

I think all you need is a class .bgNormal for the li, and then do the a declaration as .bgNormal a {...

The rest should inherit anyway.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11801994
BTW,

Sean is right about id element for an id.  the li#bgNormal is just a logical presentation of what you appeared to be trying to do. You would not want to actually do something like that.  You want to use a class.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11801997
Oops sorry Sean, stale page.

Cd&
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 11802025
No worries - time for a beer for me anyways.
0
 
LVL 4

Author Comment

by:Palamedes
ID: 11802660
OKay so, let me see..

#someID #SomeOtherIDINsomeID {

Is invalid?  





0
 
LVL 15

Expert Comment

by:Thogek
ID: 11802716
> A DIV within a the LI is illegal syntax?

No, but a <div> within an <a> is.
0
 
LVL 4

Author Comment

by:Palamedes
ID: 11802874
Aaaahhh.. Gotcha.. see now THAT I didn't know.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question