bhawin
bhawin

Reputation: 285

Div disappears on positioning it fixed

My html is like this-;

<div class="wrapper">
  <div class="header">
    this is the header
    <div class="hdr-lnks">
      <a href="#">home</a>
    </div>
  </div>
</div>

My css is this:

.hdr-lnks {
    position:fixed;
}

Why when I set position: fixed, does the div disappear?

Upvotes: 11

Views: 24764

Answers (1)

Jason
Jason

Reputation: 3360

You might have to declare where on the page you want it fixed.

For example, if you want it stuck to the top-left part of the page, your code might look like:

HTML

<div class="wrapper">
  <div class="header">
    this is the header
    <div class="hdr-lnks">
      <a href="#">home</a>
    </div>
  </div>
</div>

CSS

.hdr-lnks {
  position:fixed;
  top:0;
  left:0;
}

Here's a jsFiddle that illustrates it.

Upvotes: 20

Related Questions