Kelly Smith
Kelly Smith

Reputation: 3

CSS - Grandchild inheriting class from a different parent in IE only

I'm having an issue with Internet Explorer. I'd love to throw my hands up and say I don't want to support it, but it's not an option. Basically, I wrote an unordered list to use for navigation. Then in another section, using another parent, I used another unordered list, but it's inheriting the properties from another ID. It works completely OK in every other browser. I stripped out the essential parts of the page and am posting them below. Additionally, I checked the w3c css validator, and the warning I got said "Same colors for color and background-color in two contexts #container and #stripes ul a:link".

You'll see if you click on the bulleted list, they'll be styled like the navigation. However, when I try to change the bulleted list, it affects the navigation! I tried setting up all of the a attributes in the maincontent, but then it shuts everything down.

Can someone check this out and help? It's kinds driving me batty!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>2012 Summer Blood Challenge</title>
<style  type="text/css">

#stripes ul
{ font-size:13px;
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;

}
#stripes li
{
float:left; 
}
#stripes ul a:link,a:visited
{
display:block;
width:128px;
font-weight:bold;
color:#FFFFFF; background-image:url(https://trigger.lwcdirect.com/LWC_00486/uploadImages/2012sbc/redbar.jpg);
 background-position: bottom;
text-align:center;
padding:4px;
text-decoration:none;
height:32px;
}
#stripes ul a:hover,a:active
{
background-image:url(https://trigger.lwcdirect.com/LWC_00486/uploadImages/2012sbc/darkredbar.jpg);
}

.roundside {
    background-image: url(https://trigger.lwcdirect.com/LWC_00486/uploadImages/2012sbc/goldboxes_02.jpg);
    background-repeat: repeat-y;
    width: 560px;
    text-align: left;
    padding: 0 30px 0 30px;
}

.roundside ul {list-style-type: none;
    margin: 0;
    padding: 0;}

.roundside li {background-image:url(https://trigger.lwcdirect.com/LWC_00486/uploadImages/2012sbc/drop.gif);

    background-repeat:no-repeat;
    padding:0 0 5px 16px; font-size:16px;}

.roundside ul a:link,a:visited,a:hover,a:active {color:#990000; font-weight:bold}


</style>
</head>
<body class="oneColFixCtrHdr">
<div id="largecontainer"><!--set centering-->
        <div id="container"><!--creates box-->
            <div id="stripes">

            <center>
            <ul>
                <li><a href="#">Promotional Materials</a></li>
                <li><a href="#" style="font-size:11px">Participating Employers and Results</a></li> 
                <li><a href="#">Newsletters</a></li>
                <li><a href="#">Give Blood</a></li>
                <li><a href="#">Become a Member</a></li>
            </ul>
            </center>

            </div><!--end stripes-->
            <div id="mainContent">
                    <div class="roundside">
                    <ul>
                        <li><a href="#">Official Rules and Point Structure</a></li>
                        <li><a href="#">Gage Flyer 8.5x11</a></li>
                        <li><a href="#">2012 SBC Hero Card</a></li>
                    </ul>
                 </div>
            </div> <!-- end #mainContent -->
            <div id="footer">&nbsp;
            </div><!-- end #footer -->
        </div><!--end container-->
    </div><!-- end #largecontainer -->
</body>
</html>

Upvotes: 0

Views: 360

Answers (1)

frontendzzzguy
frontendzzzguy

Reputation: 3242

the reason your second ul within .roundside is picking up the css from the #stripes ul is because of the following css

#stripes ul a:link,a:visited

you need to change it to

#stripes ul a:link, #stripes ul a:visited

otherwise it will apply the styles declared after it to every a:visited on the site and not just in the #stripes ul

This is also the case with #stripes ul a:hover,a:active it needs to be changed to #stripes ul a:hover, #stripes ul a:hover a:active otherwise you will come across the same problems.

Hopefully this solves your problem.

EDIT: MrSlayer made a good point in the comments below which I missed.

You would also be better off changing

.roundside ul a:link,a:visited,a:hover,a:active {color:#990000; font-weight:bold}

to

.roundside ul a:link, .roundside ul a:visited, .roundside ul a:hover, .roundside ul a:active {color:#990000; font-weight:bold}

to avoid any nasty a related surprises in the future. In CSS you need to be as specific as possible when setting your styles

Upvotes: 7

Related Questions