2

My webdesign is consisted of three parts.

  • The red part is <ul>and <li>, classic list (menu).
  • Yellow part is another list in previous red list (submenu) and
  • blue part is normaly <div>.

I need the yellow list on top, blue in middle and red at the end only in HTML or CSS with z-indexes.

HTML

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
        <style>
            .menu {
                position: absolute;
                background-color: red;
                z-index: -2;
            }

            .submenu {
                z-index: 99999;
                font-size: x-large;
                background-color: yellow;
            }

            .obsah {
                position: relative;
                color: white;
                background-color: blue;
                width: 150px;
                height: 50px;
                z-index: -1;
            }
        </style>
    </head>
    <body>
        <ul class="menu">
            <li>MENU
                <ul class="submenu">
                    <li>SUBMENU</li>
                </ul>
            </li>
        </ul>
        <div class="obsah">
            DIV
        </div>
    </body>
</html>
2
  • Can you list your current html structure as well as styles? Commented Mar 9, 2015 at 1:53
  • something is missing here Commented Mar 9, 2015 at 1:53

3 Answers 3

1

this is possible if the position of the yellow and blue are absolute

.menu {
    position: absolute;
    background-color: red;
    width: 150px;
}

.submenu {
    position:absolute;
    z-index: 11;
    font-size: x-large;
    background-color: yellow;
}

.obsah {
    position:absolute;
    color: white;
    background-color: blue;
    width: 150px;
    height: 50px;
    z-index: 10;
}

demo

Sign up to request clarification or add additional context in comments.

Comments

0

I don't think you can use div with in "UL" list. However you can refer the part with :before and :after CSS Filters.

Comments

0

So something like this? Removing the position:relative; designation seemed to resolve the issue.

.menu {
    position: absolute;
    background-color: red;
    z-index: 8;
}

.menu .submenu {
    z-index: 10;
    font-size: x-large;
    background-color: yellow;
}

.obsah {
    color: white;
    background-color: blue;
    width: 150px;
    height: 50px;
    z-index: 9;
}

1 Comment

Almost, but the blue part must be middle of red and yellow (red is at the bottom and yellow on the top).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.