SitePoint Sponsor

User Tag List

Results 1 to 25 of 25
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pesky Suckerfish Nav

    This is one of those simple css issues that just fries my brain. I think I'm telling my target two things at once but can't be sure.

    I have a div with a background image that serves as navigation on this website. Only one of the three main buttons has the drop down suckerfish style navigation functionality. I set the css 'color' property to change the text to white on hover for these, but when you roll over the middle one, About The Fund, it isn't responding ... or is being overridden.

    I'm just trying to get the words "About The Fund" to change to white upon hover.

    http://elasticitydev.com/iSelectFund/

    Thanks
    | scott

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    56
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hey Scott,

    I'm a newbie myself, but the amount of questions I ask on here, I think its time I should give something back!

    I hope this works:

    #menu li ul li a:hover {
    background-color:#1c1c1c;
    padding:10px;
    display:block;
    width:306px;
    color:#FFF;

    If this doesnt work, I'm sure someone will correct me

    Cheers

  3. #3
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,254
    Mentioned
    113 Post(s)
    Tagged
    1 Thread(s)
    You're not getting it because the structure is different for that item - if you look at the other links, you've got the div & UL inside the <a> element (which, while allowed in HTML5, is clunky and clumsy and not all the browsers support it cleanly..., but for the one you're having an issue with, the <a> is inside the div and ul, so you're structure is completely different, and different rules of specificity will apply.

    Just because you place a class/id on an element doesn't mean that is the css which will be applied. Read this thread for more information.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it was something like that. I still can't seem to target it correctly. What would be a way to just tell that whole div to change color to whit on hover.

    I just tried this:

    #menu li a:hover {
    color:#FFF;
    }

    But that only works obviously when you roll over the actual anchor. I need it to light up the whole time the button is over it.

  5. #5
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,254
    Mentioned
    113 Post(s)
    Tagged
    1 Thread(s)
    This should work, but there might be browser quirks....

    #menuli:hover > a, #menu li a:hover { color: #fff; }
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  6. #6
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That definitely is working in all my current browsers. I'd like to better understand why though. It looks like you targeting the same anchor in two different ways simultaneously. I don't see how either of those is making the whole <div> area serve as a hot spot for the rollover ...

    While I was checking it in Safari 5.1.5, I noticed that it displays an underline when you hover over those same three links. I tried placing an !important on the text-decoration:none; but that didn't get it. Any idea what I need to tell Safari to get it to knock that crap off?

  7. #7
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I noticed another anomaly. It only works when you roll up on it from the bottom. If your mouse comes down on the button from the top of the screen it won't change to white until you actual are over the anchor itself.

    I'm wondering if there is maybe something I can do in jquery that will override just that one link an make it white on rollover?

  8. #8
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't see why we are even talking about styling anchors. the only element in question here is a div with class .threeNav_pos2_off.

    When you roll over that, there is code in place that should be turning that text white. I can't see why it matters that there is extra markup in this div. We seem to be saying with our css: anytime you :hover a div called .threeNav_pos2_off, turn the text white. It seems like it should be more straight forward than this.

  9. #9
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,254
    Mentioned
    113 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by scott1964 View Post
    I don't see why we are even talking about styling anchors. the only element in question here is a div with class .threeNav_pos2_off.

    When you roll over that, there is code in place that should be turning that text white. I can't see why it matters that there is extra markup in this div. We seem to be saying with our css: anytime you :hover a div called .threeNav_pos2_off, turn the text white. It seems like it should be more straight forward than this.

    See post #2 (and the link I posted there) - you're getting bit by the specificity bug. Even though the item has the class on it, the #menu li a has more hits on that element, which is why it tags them and overrides.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  10. #10
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello. I was asked to code a website that uses a very unconventional style of Nav. I don't think the designer was thinking that everything would one day need to be recreated with HTML and CSS. Anyway, what we have is more like three Nav structures in that there are three separate unordered lists being utilized. One for each button.

    Since the outer two don't have drop down suckerfish navs we don't need to worry about those, they function fine. The problem lies with the "About The Fund" button in the middle. The only way I could figure to get a dropdown suckerfish menu working on that was to nest another <ul> within an <li> of a parent list. I realize that this makes this structure unlike the other two in it's markup and that this may be causing some difficulty, but I don't think so since the div I am rolling over is higher up in the markup (meaning less nesting).

    What I'd like to see happen is when you rollover the entire div with a class="threeNav_pos2_off" the text would change to white. Again the other two are working fine so you can roll over those to see how the middle button should work. It's just that it will also slide down the suckerfish list. It may look as though this is working, but if you look close you will see that the text only changes to white if you mouse directly over the actual anchor tag. Or, for some reason, if you mouse over the button in an upward direction from the bottom. If you roll into the area from the top, the text stays dark until you encounter the anchor ...

    Somewhere in my CSS I must have something that is over riding this effect because the text stays #353535 throughout. I'm using the entire containing div (.threeNav_pos2_off) as my "hotspot" for the hover behavior.

    So, what I'd like to understand is how to make that text change it's color to white. Or if worst comes to worst, maybe I need to rebuild this entire thing. Is there a better method for doing a drop down like this when not utilizing the traditional "list" style markup for their navigation.

    http://www.savagepixels.com/iselect/
    Last edited by Paul O'B; Mar 22, 2013 at 09:33.

  11. #11
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see. So then the question becomes, how do I target this text in the "most specific" way possible? I tried adding an ID to that div which should be most specific of all, and that didn't work either.

    I tried:

    `<div class="threeNav_pos2_off inside" id="aboutTheFund">
    <ul id="menu">
    <li><a href="about.html"><p>About The Fund</p></a>
    <ul class="active">
    <li><a href="structure.html">fund structure</a></li>
    <li><a href="management.html">fund management</a></li>
    <li><a href="distribution.html">fund distribution</a></li>
    <li><a href="selection.html">company selection</a></li>
    </ul>
    </li>
    </ul>
    </div>`

    So, I added an ID to the same div with the with .threeNav_pos2_off

    My CSS looks like this:

    #aboutTheFund:hover { width:347px; height:87px; float:left; background-image:url(../img/three-nav-struct_faq_hover.png); background-repeat:no-repeat; color:#FFFFFF; }

    Didn't work. Not specific enough?

  12. #12
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This question originated in a different post and it was suggested there that specificity is the issue. I think that's true but then would need to target the text in that button in such a "specific" way that it takes precedence over and other styling. How to do that ...

    What if I add an ID to that same DIV?

    Is this even possible?

  13. #13
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,254
    Mentioned
    113 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by scott1964 View Post
    I see. So then the question becomes, how do I target this text in the "most specific" way possible? I tried adding an ID to that div which should be most specific of all, and that didn't work either.
    That's why I pointed you to that other thread in post #2- it specifically deals with this issue (I should know as I started the thread because it didn't make sense to me either). CSS selector Specificity doesn't necessarily work in a logical/programming manner. It's basically a count issue.

    #abouttheFund or .threeNav_pos2_off will never win because it's only one match on the selector scale.
    #menu li a:hover is three (#menu, li and a), so it will always win.

    There is an blog post and infographic in that thread from Andy Clarke which hopefully will explain it a little better: http://www.stuffandnonsense.co.uk/ar...city_wars.html or for just the infographic: http://www.stuffandnonsense.co.uk/ar...ywars-05v2.jpg
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  14. #14
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I read the excellent article. Thank you for posting that. My problem isn't in understanding what's wrong so much anymore as in trying to understand how to fix it. It sounds like I need to code something really convoluted in there like. Why not start at the top of the dom (or thereabouts) if that's the case.

    body .threeNavStructure threeNav_pos2_off:hover

    But that doesn't work.

    | scott

  15. #15
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,254
    Mentioned
    113 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by scott1964 View Post
    I read the excellent article. Thank you for posting that. My problem isn't in understanding what's wrong so much anymore as in trying to understand how to fix it. It sounds like I need to code something really convoluted in there like. Why not start at the top of the dom (or thereabouts) if that's the case.

    body .threeNavStructure threeNav_pos2_off:hover

    But that doesn't work.

    | scott
    I'll be honest, I'd rework that whole navigation - it's a lot more complicated than it needs to be:
    Code:
    	<ul class="threeNavStructure">
    		<li><a href="index.html">Home</a></li>
    		<li><a href="about.html">About The Fund</a>
                <ul class="active">
    				<li><a href="structure.html">fund structure</a></li>
    				<li><a href="management.html">fund management</a></li>
    				<li><a href="distribution.html">fund distribution</a></li>
    				<li><a href="selection.html">company selection</a></li>
    		   </ul>
    		</li>
    		<li><a href="faq.html">FAQ</a></li>
    	</ul>
    Then, I'd style the un-ordered list. Float the li elements, setting a common width and background-image to them. Then you can set the font-color on the hover like you had earlier.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  16. #16
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's just complicated because that's the only way I could figure to make it work. So your suggesting I treat the <ul> as though it's the containing <div>? Just eliminate the whole <div> all together? Or is the structure you suggest to be nested inside the <div> I had earlier?

    Never would have thought of that, but I'm game for anything and need to get this working.

  17. #17
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,254
    Mentioned
    113 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by scott1964 View Post
    It's just complicated because that's the only way I could figure to make it work. So your suggesting I treat the <ul> as though it's the containing <div>? Just eliminate the whole <div> all together? Or is the structure you suggest to be nested inside the <div> I had earlier?

    Never would have thought of that, but I'm game for anything and need to get this working.
    That's how I'd handle it - try to simplify the structure and the styling, and get rid of the extra cruff....unless @Paul O'B has a better approach....
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  18. #18
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure you can execute all of this in a list? Seems like list abuse ...

    Can't get them to float when doing it this way ... what the ...

    http://www.savagepixels.com/iselect/

  19. #19
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,254
    Mentioned
    113 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by scott1964 View Post
    Are you sure you can execute all of this in a list? Seems like list abuse ...

    Can't get them to float when doing it this way ... what the ...

    http://www.savagepixels.com/iselect/
    They are floating - you just need to add a margin-top to the a element (I used em, but you can pixel it out if you really want to): #primaryNavigationa{ display:block; text-decoration:none; margin-top: 2.25em; }

    Then to get your highlighting you like: #primaryNavigationli:hover, #primaryNavigation li a:hover {color: #fff; }
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  20. #20
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After doing all that markup and css work ... now I can't get anything to change to white. I was better off before. Ahhhhhhh ...

    Here's the css
    .threeNavStructure { width:1035px; height:87px; margin:0px auto 10px auto; font-family: 'Arvo', serif; }
    #primaryNavigation { text-align:center; }
    #primaryNavigation a { text-transform:uppercase; font-weight:bold; }
    .threeNavStructure ul li { float:left; }
    .homeNav_on { width:350px; height:87px; background-image:url(../img/three-nav-struct_home_on.png); background-repeat:no-repeat; padding-top:34px; color:#FFFFFF; }
    .aboutNav_on { width:338px; height:87px; background-image:url(../img/three-nav-struct_about_on.png); background-repeat:no-repeat; padding-top:34px; color:#FFFFFF; }
    .faqNav_on { width:347px; height:87px; background-image:url(../img/three-nav-struct_faq_on.png); background-repeat:no-repeat; padding-top:34px; color:#FFFFFF; }
    .homeNav_off { width:350px; height:87px; background-image:url(../img/three-nav-struct_home_off.png); background-repeat:no-repeat; padding-top:34px; }
    .aboutNav_off { width:338px; height:87px; background-image:url(../img/three-nav-struct_about_off.png); background-repeat:no-repeat; padding-top:34px; }
    .faqNav_off { width:347px; height:87px; background-image:url(../img/three-nav-struct_faq_off.png); background-repeat:no-repeat; padding-top:34px; }
    .homeNav_off:hover { background-image:url(../img/three-nav-struct_home_hover.png); }
    .aboutNav_off:hover { background-image:url(../img/three-nav-struct_about_hover.png); }
    .faqNav_off:hover { background-image:url(../img/three-nav-struct_faq_hover.png); }
    .homeNav_on a { color:#FFFFFF; }
    .aboutNav_on a { color:#FFFFFF; }
    .faqNav_on a { color:#FFFFFF; }
    .homeNav_off:hover a { color:#FFFFFF; }
    .aboutNav_off:hover a { color:#FFFFFF; }
    .faqNav_off:hover a { color:#FFFFFF; }

    Sure like to get that darn text white on rollover and when you are on that page. Obviously I'm not targeting the anchors correctly or they are getting overridden. Am I just doing something stupid?

    http://www.savagepixels.com/iselect/index.html

  21. #21
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,296
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Threads merged

  22. #22
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,296
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Is the issue still that you want the "About the Fund" text to turn white while hovering over that menu and/or the dropdown but that you don;t want the other two menus at either side to turn white?

    If so just target it like this:

    Code:
    li.aboutNav_off:hover > a,
    li.aboutNav_on:hover > a {color:#fff}

  23. #23
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks everyone. I think I have it working now. And yet I still don't really understand what was going on. I got the white colors to work by using !important. That seemed to do it which tells me it was getting overridden from someplace. I'd like to understand where so I can avoid it going forward.

    http://www.savagepixels.com/iselect/index.html

    .homeNav_on a { color:#FFFFFF !important; }
    .aboutNav_on a { color:#FFFFFF !important; }
    .faqNav_on a { color:#FFFFFF !important; }
    .homeNav_off:hover a { color:#FFFFFF !important; }
    .aboutNav_off:hover a { color:#FFFFFF !important; }
    .faqNav_off:hover a { color:#FFFFFF !important; }

    Special thanks to Paul and Dave!

  24. #24
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,296
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    You don't need important just qualify the rules with the tag name to give them more specificity.

    The problem is that you have over-ridden the rules with a:link and a:visited later in the code (you really should keep the reset and default styles at the top of the stylesheet to avoid conflicts like this).

    Code:
    .homeNav_on a { color:#FFFFFF }
    .aboutNav_on a { color:#FFFFFF }
    .faqNav_on a { color:#FFFFFF }
    .homeNav_off:hover a { color:#FFFFFF }
    .aboutNav_off:hover a { color:#FFFFFF}
    .faqNav_off:hover a { color:#FFFFFF }
    
    /* compulsories */
    body { font-family: 'Open Sans', sans-serif; background:#353636 url(../img/site_bg.jpg) top center no-repeat; color:#353535; }
    .after { display:block; clear:both; height:0px; visibility:hidden; }
    a:link { color:#293952; text-decoration:none; }
    a:visited { color:#293952; text-decoration:none; }
    .homeNav_on{} ( without !important) and a:link{} have the same specificity so the one that is later in the stylesheet wins out. If you moved a:link and a:visited to the top of the stylesheet then there would be no need for !important. The sitepoint reference has a good explanation on Specificity (because I wrote it ). If you still have trouble then use a specificity calculator and then you can see which has the higher specificity and will win out.

  25. #25
    SitePoint Zealot
    Join Date
    Aug 2010
    Location
    Wilmette, IL
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DOH!

    Thanks Paul. I knew about that. What I did, which was stupid, was to move those rules up to the top while I sorted out the CSS. (Dreamweaver always returns you to the top of the CSS page when you click the tab ... which gets to be a major pain if you are always working towards the bottom of the sheet. Anyway, then, after I was done I was gonna move them back to their place ... never remembering about the precedence determined by actual location on the style sheet.

    Thanks again to all who helped!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •