Menu does not stick under the header

0

I have a video in html5 at the top of the page and then a menu below it that should be fixed as we scroll the page like this > site here .

But I do not know the correct way to do this, remembering that this has to work in all browsers including Internet Explorer:

The following is my code:

@import url(http://fonts.googleapis.com/css?family=Dancing+Script);
@import url(http://fonts.googleapis.com/css?family=Scada);
@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro);
 html,
body {
  margin: 0;
  padding: 0;
}
a {
  text-decoration: none;
  outline: none;
}
button {
  cursor: pointer;
  outline: none;
}
ul li {
  list-style-type: none;
}
header {
  position: relative;
  top: 0;
  overflow: hidden;
  width: 100%;
  height: 90%;
  min-height: 800px;
}
video {
  height: 710.4375px;
  width: 100%;
  z-index: -1;
  position: absolute;
  top: 0;
  left: 0;
  -webkit-transform: scaley(1.72);
  -o-transform: scaley(1.72);
  -ms-transform: scaley(1.72);
  -moz-transform: scaley(1.72);
  transform: scaley(1.72);
  z-index: -2;
}
#bg-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url(../images/overlay.png);
  z-index: -1
}
.texto-header {
  position: absolute;
  top: 30%;
  left: 50%;
  margin-left: -280px;
  width: 600px;
  text-align: center;
  z-index: 2;
  color: #FFF;
}
.texto-header h1 {
  font-family: 'Dancing Script', cursive;
  font-size: 3.5em;
}
.texto-header p {
  /*font-family: 'Scada', sans-serif;*/
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 1em;
  line-height: 20px;
}
.texto-header button {
  color: #fff;
  background: transparent;
  border: 2px solid #fff;
  width: 220px;
  height: 50px;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 1.2em;
  border-radius: 5px;
  margin-top: 5%;
}
.texto-header button:hover {
  color: #000;
  background-color: #fff;
}
.menu-header {
  margin-top: 0px;
  position: absolute;
  top: auto;
  bottom: 0px;
  background-color: lime;
  width: 100%;
  height: 100px;
}
.menu {
  margin: 40px auto;
  text-align: center;
}
.menu li {
  display: inline;
}
.menu li a {
  margin: 15px;
}
<header>
  <div id="video">
    <video id="Video1" id="bgvid" autoplay loop>
      <source src="video/animacao-lol.mp4" type="video/mp4" />desculpe mais seu navegador não suporta este formato ou esta desatualizado :(
    </video>
  </div>
  <div id="bg-video"></div>

  <div class="texto-header">
    <h1>Olá amigos somos a <strong>Tec Mov!</strong></h1>
    <p>dolor sit amet, consectetur adipiscing elit. Sed at risus neque.
      <br>Cras sit amet ligula ut justo commodo porta id ut enim. Nulla est lectus, mollis sit amet vehicula id, volutpat eget mauris.</p>
    <button>Vamos Começar ?</button>
  </div>

</header>

<nav class="menu-header">
  <ul class="menu">
    <li><a href="">Home</a>
    </li>
    <li><a href="sobre.html">Sobre</a>
    </li>
    <li><a href="games.html">Games</a>
    </li>
    <li><a href="eventos.html">Eventos</a>
    </li>
    <li><a href="team.html">Team</a>
    </li>
    <li><a href="contato.php">Contato</a>
    </li>
    <li><a href="">Noticias</a>
    </li>
    <li><a href="http://www.novaerateam.com.br/forum/" target="_blank">Forum</a>
    </li>
  </ul>
</nav>
    
asked by anonymous 10.06.2015 / 21:06

1 answer

1

There are some errors and improvements that should be made in your code, such as not using two ids in the same div:

<video id="Video1" id="bgvid" autoplay loop>

Here you should only use id and class , or apply the styles of the second id to video1 so that you only get a single id . Example using id and class :

<video id="Video1" class="bgvid" autoplay loop>

But I spent a bit of time here and restructured all your code completely and also added a responsive video to the first section in the right way:

$(document).scroll(function() {
    var navHeight = $( window ).height() - 70;
    if ($(window).scrollTop() > navHeight) {
        $('nav').addClass('fixed');
    }
    else {
        $('nav').removeClass('fixed');
    }
});
/* Este CSS faz o video preencher a 100% o seu Recipiente */
.videoRecipiente {
    height:100%;
    overflow: hidden;
}
.videoRecipiente video {
    min-width: 100%;
    min-height: 100%;
}
.textoSobreVideo {
    color: #fff;
    position: absolute;
    bottom: 60px;
    text-align: center;
    width: 100%;
}

/* Esta class é adicionada ao fazer - scroll */
.fixed {
    position: fixed; 
    top: 0; 
    height: 70px; 
    z-index: 1;
}
body {
    color: #fff;
    font-family: 'open-sans-bold'; 
    font-size: 18px;
    text-align: center;
}
section {
    height: 88vh;
}

/* Navegação */
nav {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 70px;
    background: #fff;
}
nav ul {
    margin: 0;
    padding: 0;
}
nav li {
    display: inline-block;
    padding: 24px 10px;
}
nav li a {
    color: #757575;
    text-transform: uppercase;
}

/* Seccões */
#screen1 {	
    background: #43b29d;
}
#screen2 {
    background: #efc94d;
}
#screen3 {
    background: #e1793d;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script><sectionid="screen1">
    <div class="videoRecipiente">
        <video autoplay loop muted>
            <source src="http://www.w3schools.com/html/mov_bbb.mp4"type='video/mp4;codecs="avc1.42E01E, mp4a.40.2"'>
            <source src="http://www.w3schools.com/html/mov_bbb.mp4"type='video/webm;codecs="vp8, vorbis"' />
                Este video não é suportado pelo seu navegador.
            </video>
            <div class="textoSobreVideo">
                <p>Olá amigos somos a <strong>Tec Mov!</strong></p>
            </div>
    </div>
	<nav>
        <ul>
            <li><a href="#">Início</a></li>
            <li><a href="#">Sobre</a></li>
            <li><a href="#">Games</a></li>
            <li><a href="#">Eventos</a></li>
            <li><a href="#">Contactos</a></li>
        </ul>
	</nav>
</section>
	
<section id="screen2"></section>
<section id="screen3"></section>
  

It has attention that the jQuery library should be implemented in   preference within the <head> tag of your site and not somewhere in the middle of your <body> , this was just an example for   that the code worked correctly.

Example:

<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script></head>

YoualsohaveanexampleinjsFiddle link of the code mentioned above and also another version of the menu, which only appears when you scroll up link

    
11.06.2015 / 01:16