0

I have a landing menu that is made from SVG icons, and now I want to position a div behind these icons, but still inside the menu. Both of these elements have position:fixed, and top set as a percentage.

So what I want to do is to have the landingMenu in the back, then the landingMenuOrangeLine, then the miniNavButton (so the buttons are in front)

What I wanted to do is set the z-index of the elements in question in order to make the buttons appear in front of the div. Now what happens is that I set the z-index of .miniNavButton to 2, but when I inspect the element in the developer tools it says z-index:auto.

Can anyone point out what I'm doing wrong? I've setup a codepen in case you want to play around with it.

my html:

<div class="landingMenu">
    <div id="introductionButton" class="miniNavButton" (click)="changeState('landing')">
        <a>
            <svg class="icon icon-user">
                <use xlink:href="symbol-defs.svg#icon-user"></use>
            </svg>
        </a>
    </div>
    <div id="skillsButton" class="miniNavButton" (click)="changeState('skills')">
        <a>
            <svg class="icon icon-book">
                <use xlink:href="symbol-defs.svg#icon-book"></use>
            </svg>
        </a>
    </div>
    <div id="contactButton" class="miniNavButton" (click)="changeState('contact')">
        <a>
            <svg class="icon icon-envelop">
                <use xlink:href="symbol-defs.svg#icon-envelop"></use>
            </svg>
        </a>
    </div> 
</div>

<div id="landingMenuOrangeLine"></div>

my css:

.landingMenu {
  top: 1%;
  position: fixed;
  width: 100%;
  border-top: 0.1em solid white;
  border-bottom: 0.1em solid white;
  padding: 0.5em;
  background-color: #00B16A;
}

#landingMenuOrangeLine {
  width: 100%;
  height: 0.3em;
  background-color: #FF4C00;
  position: fixed;
  top: 5%;
  z-index: 1;
}

.miniNavButton {
  background-color: #4DC594;
  padding: 1em;
  margin: 0 7.5%;
  border-radius: 50%;
  display: inline-block;
  z-index: 2;
}

.icon-user,
.icon-book,
.icon-envelop,
.icon-eye,
.icon-embed,
.icon-hammer {
  width: 2em;
  height: 2em;
}

.contactLink {
  display: none;
}
Miha Šušteršič
  • 9,742
  • 25
  • 92
  • 163

4 Answers4

0

Simple

.landingMenu {
    position: relative;
    z-index: 1;
}
#landingMenuOrangeLine{z-index:0;}
Creative Enemy
  • 399
  • 4
  • 22
0

I think it's caused by your styles/HTML class names. .landingmenu should be .landingMenu.

See this Are class names in CSS selectors case sensitive?

If you want to have the .landingMenuOrangeLine follow the z-index, place it inside the .landingMenu.

Community
  • 1
  • 1
dork
  • 4,396
  • 2
  • 28
  • 56
0

You have a typo error : it's .landingMenu not .landingmenu

You also can play with the z-index property of it to make it appears in front of the orange line or behind.

EDIT

To make it have the desired output, you have to put your .miniNavButton in the same level of the two other div and put it in relative position. See codepen updated.

Codepen

Vincent G
  • 8,547
  • 1
  • 18
  • 36
0

Try with this below css by replacing..

#landingMenuOrangeLine {
  width: 100%;
  height: 0.3em;
  background-color: #FF4C00;
  position : absolute ;
  top : 50px;
  z-index : -1;
}

.miniNavButton {
  background-color: #4DC594;
  border-radius: 50%;
  width : 50px;
  height : 50px;
  display: inline-block;
  margin : 30px;
}

jsFiddle link https://jsfiddle.net/iqbalp95/3bekxmoj/1/

Iqbal Pasha
  • 1,318
  • 1
  • 8
  • 12