z-index does not work when you try to add a text about the video?

0

Good, I'm trying to add a text on a video that is in the background, the video works correctly but when trying to put the text the z-index does not work, someone has an idea why?

My code:

body{
	margin:0;
}

video {

	 position:fixed;
	 min-height:100%;
	 min-width:100%;
	 top: 50%;
	 left: 50%;

	 transform: translateX(-50%) translateY(-50%);


z-index: 1;  



}
<!DOCTYPE html>
<html lang="es">
<head>
	<title>example video</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
	<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.css">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

</head>
<style type="text/css">
  
.logo {

  border-radius:50%;
}

</style>
<body>

<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="#">Fixed navbar</a>
  <div class="collapse navbar-collapse justify-content-end" id="navbarCollapse">
    <ul class="navbar-nav flex-row w-100">
      <li class="nav-item px-2 mr-auto active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item px-2">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item px-2">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>
  </div>
</nav>
<video src="file:///home/sommer0123/Downloads/videoplayback.mp4" autoplay  loop>
	

</video>
<h1>Funciono</h1>
</body>


<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
 
</html>
    
asked by simon 07.12.2017 в 03:07
source

2 answers

1

You have the video in position:fixed to overlay something on it you have to have the same property and there is if the z-index works I leave the example with the changes in the h1 I hope you help greetings.

body{
	margin:0;
}

video {

	 position:fixed;
	 min-height:100%;
	 min-width:100%;
	 top: 50%;
	 left: 50%;

	 transform: translateX(-50%) translateY(-50%);


z-index: 1;  



}
/*Nuevo codigo*/
video + h1 {
  z-index:100;
  position:fixed;
  top:50%;
  left:50%;
  transform: translate(-50%,-50%);
  font-size:100px;
}
/*Nuevo codigo*/
<!DOCTYPE html>
<html lang="es">
<head>
	<title>example video</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
	<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.css">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

</head>
<style type="text/css">
  
.logo {

  border-radius:50%;
}

</style>
<body>

<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="#">Fixed navbar</a>
  <div class="collapse navbar-collapse justify-content-end" id="navbarCollapse">
    <ul class="navbar-nav flex-row w-100">
      <li class="nav-item px-2 mr-auto active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item px-2">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item px-2">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>
  </div>
</nav>
<video id="video" autoplay loop class="embed-responsive-item">
        <source src="//clips.vorwaerts-gmbh.de/VfE_html5.mp4" type=video/mp4>
    </video>
<h1>Funciono</h1>
</body>


<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
 
</html>
    
answered by 09.12.2017 в 01:03
0

So that the text h1 is on the video the z-index of h1 must be greater than the video example:

h1 {
  z-index: 1;
}

and the video

video {
 z-index: 0;
}
    
answered by 07.12.2017 в 07:09