javascript - Overlaying a Fixed Header Over Elements When Scrolling - Stack Overflow

I have a fixed header, so that when I scroll it remains at the top of the page so that visitors may nav

I have a fixed header, so that when I scroll it remains at the top of the page so that visitors may navigate quickly or skip sections of the page.

Here is a picture of my problem:

The problem is pretty simple - I want my header to float over the top of any other objects instead of being hidden by them, but I assume there isn't a way to do it without javascript. Here is my CSS:

#primary header {
position: fixed;
margin: 0;
padding: 0; 
width: 100%;
height: 50px;
background-color: rgb(49,49,49);
}
nav { /* positions nav menu */
position: fixed; /* keeps the nav bar fixed at top when scrolling */
top: 1.25%;
left: 27%;

}
nav a {
margin: 0 50px;
padding: 10px 20px;
font-size: 20px;
}

Anyway I can do this? I am not familiar with Javascript, but would love some help!

I have a fixed header, so that when I scroll it remains at the top of the page so that visitors may navigate quickly or skip sections of the page.

Here is a picture of my problem:

The problem is pretty simple - I want my header to float over the top of any other objects instead of being hidden by them, but I assume there isn't a way to do it without javascript. Here is my CSS:

#primary header {
position: fixed;
margin: 0;
padding: 0; 
width: 100%;
height: 50px;
background-color: rgb(49,49,49);
}
nav { /* positions nav menu */
position: fixed; /* keeps the nav bar fixed at top when scrolling */
top: 1.25%;
left: 27%;

}
nav a {
margin: 0 50px;
padding: 10px 20px;
font-size: 20px;
}

Anyway I can do this? I am not familiar with Javascript, but would love some help!

Share Improve this question edited Jun 9, 2014 at 14:22 iCollect.it Ltd 93.7k26 gold badges187 silver badges208 bronze badges asked Jun 9, 2014 at 14:20 Taylor JohnsonTaylor Johnson 4841 gold badge9 silver badges21 bronze badges 1
  • 1 Looks like you just need to use the css z-index property – Razzildinho Commented Jun 9, 2014 at 14:24
Add a ment  | 

2 Answers 2

Reset to default 7

Set the css z-index property on your fixed element. The higher the value, most in front it will get...

Like:

#primary header   {
    z-index: 999; /* SET THE NEEDED AMOUNT */
}

The z-index property is a mon solution to elements which are positioned, but it looks like YouTube has provided a solution as well.

Add a parameter to force YouTube iframe to set a low z-index.

If you have any element you’ll like to show above a YouTube iframe you just have to add a parameter to the iFrame URL.

Ricard Torres' Personal Blog

<iframe width="560" height="315" src="//www.youtube./embed/0HxNtWEIKhQ?wmode=transparent" frameborder="0" allowfullscreen></iframe>

JSFiddle didn't seem to reproduce the issue, but here is an example as well:

JSFiddle Example

StackOverflow Duplicate Question

YouTube API Documentation (Preferable Embedding Method)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745144484a4613584.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信