lundi 6 juillet 2020

CSS and HTML dropdown with wrond z-index compared to parents

I'm new to html and css and working on a basic website. I've tried to make a navigation bar on to of the page that has "position: fixed". However, when the dropdown slides in from the top it slides over the navigation bar instead of under it. Any help would be apreciated. Thanks.

<div class="headBanner" id="headBanner">
        <div id="logo" onclick="location.href = 'Welcome.html';"></div>
        <button type="button" id="choice2" onclick="location.href = 'InvestingHome.html';">Investing</button>
        <button type="button" id="choice3" onclick="location.href = 'EarlyStartHome.html';">Early Start</button>
        <button type="button" id="choice4" onclick="location.href = 'RetirementHome.html';">Retirement</button>
        <button type="button" id="choice5">Community</button>
        <div id="tab1"></div>
        <div id="tab2"></div>
        <div id="tab3"></div>
        <div id="tab4"></div>
        <div id="tab5"></div>
        <button type="button" id="loginButton"></button>
        <div class="dropdown" id="dropdown">
            <button class="dropbtn" type="button" id="financeChoice" onclick="location.href = 'FinancesHome.html';">
                Finance
                <i class="fa fa-caret-down"></i>
            </button>
            <div class="dropdown-content">
                <div id="topDropdown">
                    <div class="innerSpace" id="innerSpace1">
                        <h2 id="coursesHead">Courses</h2>
                        <ol id="coursesList">
                            <li onclick="location.href = 'Finances-intro1-Course.html';">Introduction</li>
                            <li onclick="location.href = 'Finances-TandP1-Course.html';">Tracking And Planning</li>
                            <li onclick="location.href = 'Finances-CDB1-Course.html';">Credit, Debt and Banking</li>
                            <li onclick="location.href = 'Finances-Savings1-Course.html';">Saving</li>
                            <li onclick="location.href = 'Finances-Taxes1-Course.html';">Taxes</li>
                        </ol>
                    </div>
                    <div class="innerSpace" id="innerSpace2">
                        <h2 id="toolsHead" onclick="location.href = 'financeToolOverview.html';">Financial Tool</h2>
                    </div>
                    <div class="innerSpace" id="innerSpace3">
                        <h2 id="articlesHead">Articles</h2>
                    </div>
                </div>
            </div>
        </div>
    </div>

And here is the css:

.headBanner {
    height: 10vh;
    width: 100%;
    clear: top;
    background-color: #007AFF;
    position: fixed;
    z-index: 100;
}

.dropdown-content {
    visibility: hidden;
  display: block;
  position: relative;
  background-color: #8FC4FF;
  min-width: 160px;
  z-index: 1;
  top: 100%;
  width: 100%;
  height: 30vh;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    padding: 12px 16px;
    opacity: 0;
}

.dropdown:hover .dropdown-content {
    display: block;
    animation: bannerFadeIn 0.25s linear forwards;
    visibility: visible;
    opacity: 1;
    z-index: 0;
    position: absolute;
    top: 30%;
}

@keyframes bannerFadeIn {
  from {
    opacity: 0;

    transform: translateY(-300px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

enter image description here enter image description here The big orange thing in the background has z index of 1.




Aucun commentaire:

Enregistrer un commentaire