I have a h1 tag stuck behind my video
(I’m new to programming if this sounds like a stupid question)
I tried putting a header over a video and it didn’t work. I’ve tried putting z-index but they don’t seem to work
code |
V
<!DOCTYPE html>
<html>
<head>
<body>
<h1 class="skyeHeader">SkyeMrGamez</h1>
</body>
<video autoplay muted loop id="landingImage">
<source src="landingBackground.mp4" type="video/mp4" />
</video>
<style>
.skyeHeader {
text-align: center;
font-family: Arial, Helvetica, sans-serif;
color: #ff0061;
}
#landingImage {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
filter: blur(1.5rem);
}
</style>
</head>
</html>
3
Answers
Please put "position: relative;" and "z-index: 9;" in "skyeHeader" class property.
.skyeHeader {
text-align: center; font-family: Arial, Helvetica, sans-serif; color: #ff0061; position: relative; z-index: 9;}
video element has a higher z-index value by default. To fix this, you can try setting a higher z-index value for your h1 element.
For z-index to work, your skyeHeader’s position should be either absolute or relative, that’s the reason z-index was not working for you.
However i suggest you change the z-index of the video to be -1 instead, that way your video will act as a background to the content you put on top:
Also, Your video tag should be within your page’s body, this won’t have a behavior change because modern browsers fix up the DOM automatically, but this is a good practice.
Hope this helps, good luck with the learning!