Joe Pigott
Joe Pigott

Reputation: 8469

Opacity not working on header div

Fiddle

I am trying to make the div #top opacity: 50%, so when you scroll, it will show a faded portion of the webpage below it. When I run this, however, it does not show opacity. It still shows solid.

CSS:

#top {
  width: 100%;
  height: 40px;
  background: #96f226;
  text-align: center;
  font-size: 30px;
  color: #252525;
  position: relative;
  position: fixed;
  opacity: 50%;
}

HTML:

<div id='top'>Cuisine List</div>

Upvotes: 0

Views: 258

Answers (1)

tckmn
tckmn

Reputation: 59303

opacity takes a decimal between 0 and 1, like so:

opacity: 0.5;

See MDN for more information.

Also,

  • you seem to have two positions - you should remove the first one
  • for position: fixed to work, you must specify at least one location, such as:

    top: 0px;
    

    which will anchor it to the top.

fixed fiddle

Upvotes: 2

Related Questions