Grow your CSS skills. Land your dream job.

Pseudo Element AND Selector.

  • # November 25, 2011 at 2:22 am

    Is it possible to have a Pseudo Element and Selector in the same css tag?


    /*DROPDOWN*/

    #header #navigation{height:40px; margin-top:-33px;padding:10px 10px 15px 10px; border-radius:8px; background-color:#FFF; }
    /*
    LEVEL ONE
    */
    ul.dropdown { position: relative;bottom:3px;}
    ul.dropdown li { font-weight: normal; float: left; zoom: 1; background: #fff; }
    ul.dropdown a:hover { color: #000; }
    ul.dropdown a:active { color: #FFF; }
    ul.dropdown li a { display: block; padding: 7px 18px; border-right: 1px solid #CCC;
    color: #222; }
    ul.dropdown li a:hover :first-child { border-radius:8px; } /* Doesn't work in IE */

    ul.dropdown li:last-child a { border-right: none; } /* Doesn't work in IE */

    ul.dropdown li.hover,
    ul.dropdown li:hover { background: #9ACD32; color: black; position: relative; } /*F3D673*/
    ul.dropdown li.hover a { color: black; }


    /*
    LEVEL TWO
    */
    ul.dropdown ul { width: 200px; visibility: hidden; position: absolute; top: 100%; left: 0; }
    ul.dropdown ul li { font-weight: normal; background: #333333; color: #FFF;
    border-bottom: 1px solid #666; float: none; }

    /* IE 6 & 7 Needs Inline Block */
    ul.dropdown ul li a { border-right: none; width: 100%; display: inline-block; color:#FFF;}

    /*
    LEVEL THREE
    */
    ul.dropdown ul ul { left: 100%; top: 0; }
    ul.dropdown li:hover > ul { visibility: visible; }


    something like that?

    # November 25, 2011 at 2:31 am

    Got it with

    ul.dropdown li:first-child,
    ul.dropdown li a:hover{ border-radius:6px 0 0 0; } /* Doesn't work in IE */

    ul.dropdown li:last-child,
    ul.dropdown li a:hover{ border-radius:0 6px 0 0; } /* Doesn't work in IE */

    But it also applies it to the first and Last of each drop down (level) list as well. trying to fix that now.

    # November 27, 2011 at 4:53 am

    http://twitpic.com/7kivlg/full

    look at the windows link. (the corner) the top right corner is rounded.

    same goes with the first top left corner of the dropdown for each level.

    I only want the top left of home and top right of contact corners to be rounded. ive tried giving them seperate selectors but again, it wasn’t working?

    # November 27, 2011 at 6:40 am

    in other words, you dont want them to be rounded in your sub navigation? I’m not sure i completely understand but if that is the case try this:


    /*targets all li and a tags within the dropdown */
    ul.dropdown li:first-child,
    ul.dropdown li a:hover{ border-radius:6px 0 0 0; } /* Doesn't work in IE */

    /*targets all li and a tags within the dropdown */
    ul.dropdown li:last-child,
    ul.dropdown li a:hover{ border-radius:0 6px 0 0; } /* Doesn't work in IE */

    /*targets only 2nd level*/
    ul.dropdown ul li:first-child,
    ul.dropdown ul li a:hover{ border-radius: none; }

    /*targets only 2nd level*/
    ul.dropdown ul li:last-child,
    ul.dropdown ul li a:hover{ border-radius: none; }

    /*targets only 3rd level*/
    ul.dropdown ul ul li:first-child,
    ul.dropdown ul ul li a:hover{ border-radius: none; }

    /*targets only 3rd level*/
    ul.dropdown ul ul li:last-child,
    ul.dropdown ul ul li a:hover{ border-radius: none; }

    You can obviously shorten it by using commas since the same rules apply for both 2nd and 3rd level first and last children…but this way you see what i hope is the proper way to select each level…I can;t see the HTML structure, so i am just making an educated guess…

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".