SitePoint Sponsor

User Tag List

Results 1 to 25 of 36

Threaded View

  1. #1
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Hampshire UK
    182 Post(s)
    6 Thread(s)

    CSS -Test Your CSS Skills #39 - dropdown arrows

    CSS - Test Your CSS Skills Number 39 - dropdown arrows: Quiz now ended: Solution in post #32

    On my CSS "wishlist" is the "parent selector" that would give you the ability to style the parent of a child using the child as the reference. Or similarly the ability to style a parent element based on the child element that it contains. Alas there is no such thing in CSS - yet.

    That's all well and good but where is that leading us?

    In this quiz I will be asking you to perform the above feat in some respects in that I want you to automatically add indicator arrows to show that the item contains a dropdown menu. Essentially if a list element contains a dropdown menu then show an arrow.

    It may be easier to look at the attachment first so you can get an idea of what I am talking about.

    Are you back yet? Good lets begin.

    You can see that the arrow is only showing on elements that contain dropdowns which is a good visual aid and helps differentiate between elements that don't have dropowns attached.

    The puzzle is to add these arrow icons automatically so that if the menu items are changed and flyouts removed or added to different items then the indicator arrows would automatically reflect this change without the need to change any css or html.
    Also the arrow should change colour when items are hovered as shown in the attachment.

    You can use your own css but the html between the body tags must remain untouched.

    Here is the starting code:

    <ul id="nav">
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a>
                <li><a href="#">History</a></li>
                <li><a href="#">Team</a></li>
                <li><a href="#">Offices</a></li>
        <li><a href="#">Test</a></li>
        <li><a href="#">Services</a>
                <li><a href="#">Web Design</a></li>
                <li><a href="#">Internet Marketing</a></li>
                <li><a href="#">testing</a>
                        <li><a href="#">test 1</a></li>
                        <li><a href="#">test 2</a></li>
                        <li><a href="#">test 3</a></li>
                        <li><a href="#">testing</a>
                                <li><a href="#">test 1</a></li>
                                <li><a href="#">test 2</a></li>
                                <li><a href="">PMOB</a></li>
                                <li><a href="#">test 4</a></li>
                                <li><a href="#">test 5</a></li>
                        <li><a href="#">test 4</a></li>
                        <li><a href="#">test 5</a></li>
                <li><a href="#">Hosting</a></li>
                <li><a href="#">Domain Names</a></li>
                <li><a href="#">Broadband</a></li>
        <li><a href="#">Contact Us</a>
                <li><a href="#">United Kingdom</a></li>
                <li><a href="#">France</a></li>
                <li><a href="#">USA</a></li>
                <li><a href="#">Australia</a></li>
    To save you re-inventing the wheel you can find basic css for dropdowns from the original suckerfish site, or from one of my old demos, or perhaps even from Jason's (Deathshadow) clever overflow version.


    There are always rules

    Must work in IE8+ and modern Safari, Chrome, Firefox and Opera (don't bother with ie7 and under).

    Assume that only three levels of menus exist as per the attachment (any more than that is nonsense anyway most of the time).

    Remember that the menu order could change and the flyouts added or removed so you can't rely on sub menus being the third element along or down etc ( e.g. this won't work li + li + li{}). You must make your code cope automatically.

    Valid html and css (css2.1 or 3) (but I am also interested in non valid approaches if its interesting).

    No scripts of any kind (unless you want to add support for IE7 and under because you found this quiz too easy).

    You can use whatever CSS rules you like but the html must be untouched and no extra elements added.

    I think that covers everything but if anything is still unclear or I have made an error in my logic then just shout. The winner won't necessarily be the first correct one I receive (but the first entry always gets a big mention and may indeed be the preferred solution).

    Remember this is just for fun and there are no prizes. Your reward will be knowing how smart you are.

    Don't post your answers in this thread but PM with the details instead so that all can have a go.

    Have fun.

    PS. : In case you missed the other tests you can find them all listed here:
    Attached Images Attached Images


Posting Permissions

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