0

http://rpedrosa.com/efinancial/

In this page, I am trying to make the sign in box slide overlaying the other content, but it always comes under it, even after setting z-index: 999. Any help?

Here's my code:

HTML:

<nav>
    <ul id="primary-nav">
        <li><a href="#">All jobs</a></li>
        <li><a href="#">Candidates</a></li>
        <li><a href="#">Recruiters</a></li>
        <li><a href="#">About Us</a></li>
        <li><a href="#">Help</a></li>
        <li><a href="#">Contact Us</a></li>
        <li id="login-link"><span class="fa fa-user user-icon"></span>Sign In <span class="fa fa-chevron-down chevron-icon"></span></li>
    </ul>
    <div id="signin-box">
        <form id="form-signin" action="">
            <label for="username">Username</label>
            <input type="text" name="username">
            <label for="password">Password</label>
            <input type="text" name="password">
            <button type="submit">Sign In</button>
            <div>Not registered?</div>
            <button type="button">Sign Up</button>
        </form>
    </div>
</nav>

CSS:

header nav {
    float:right;
    position:relative;
    margin:20px 0;
    height:50px;
}

div#signin-box {
    position:absolute;
    top:50px;
    right:0;
    background-color:#015163;
    padding:20px;
    color:#FFF;
    font-size:18px;
    z-index:999;
    display:none;
}

Thanks in advance! :)

rjpedrosa
  • 652
  • 2
  • 7
  • 10

3 Answers3

3

This issue is being created by the overflow: hidden; in your .inner class, to solve this, you need to remove it and replace it with a height instead. Here's how to do it:

.inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 90px;
  padding: 20px;
}
1

It's actually not behind the other element, it's being clipped by the .inner element which has overflow: hidden; applied to it.

Evidently you are using this for clearfix purposes, which means we will need an alternate clearfix, such as the popular :after clearfix.

If you replace:

.inner {
    margin: 0 auto;
    max-width: 1200px;
    overflow: hidden;
    padding: 20px;
}

With:

.inner {
    margin: 0 auto;
    max-width: 1200px;
    padding: 20px;
}
.inner:after {
    clear: both;
    content: "";
    display: table;
}

It will work.

Community
  • 1
  • 1
Alexander O'Mara
  • 58,688
  • 18
  • 163
  • 171
1

This is a bit tricky. But this will work (although it may create another problem due to the way you code the css)

  1. Remove overflow attribute from .inner css class
  2. Under the <section id="search">..</div> add <div style='clear:both'></div>

It should look like the following:

<header>...</header>
<div style='clear:both'></div>
<section id="search">...</section>
<div style='clear:both'></div>
<section id="search">...</section>

You should use clear:both to clean up float. It'll work better than using overflow:hidden;

syanaputra
  • 590
  • 1
  • 5
  • 12