Search code examples
htmlcssz-index

Z-index with higher value is not placing over lower valued ones


I'm having troubles getting a z-index value element with a higher integer to place over another.

This is the issue I am facing.

enter image description here

The bottom half of the register button is being overlapped by the background image.

The code below has been adjusted a bit to only show the code that is being used here. You can see the full site by visiting: https://stangline.com/.

Here is the code:

CSS

.buttonFrame {
    margin: 80px auto 50px auto;
    display: block;
    z-index: 4;
    position: relative;
}
.buttonList {
    display: inline-block;
    vertical-align: top;
}
.homeButton {
    font-size: 2rem;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: .2rem;
    padding: 20px;
    cursor: pointer;
    box-sizing: border-box;
    -webkit-transition: all 0.3s ease-in-out;
    transition: all 0.3s ease-in-out;
    position: relative;
    z-index: 4;
}
#homeRight {
    width: 60%;
    height: 100%;
    position: absolute;
    right: 0;
    top: 0;
    display: block;
    z-index: 2;
}
#homeRightImgFill {
    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    width: 95%;
    position: relative;
    margin: 0 auto;
    padding-top: 50%;
    z-index: 2;
}

HTML

<div class="buttonFrame">
    <a href="/forums" class="homeButton homeButtonGradient buttonList">
        Visit Forum
    </a>
    <a href="/register/" class="homeButton buttonList homeButtonBlue p-navgroup-link--register" data-xf-click="overlay" data-follow-redirects="on">
        <span>Register</span>
    </a>    
</div>
</div>
</div>
</div><div class="homeCont" id="homeRight">
    <div id="homeRightImgFill"></div>
</div>

Solution

  • Apply z-index:4 on homeCont class