Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Video Positioning

Hello everyone,

I'm currently working on a web project and I'm having trouble positioning a video element below my navigation bar in a responsive manner. No matter what I try, I can't seem to get it right.

Here's what I've attempted so far:

<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Digital Symphony</title>
<link rel="icon" href="ikon.jpg">
<link rel="stylesheet" href="tickets.css">
<script src="script.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?f...amily=Shantell+Sans:wght@300;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?f...amily=Shantell+Sans:wght@300;500&display=swap" rel="stylesheet">
</head>
<body>
<!-- Meny -->
<nav class="navigation">
<ul>
<li><a href="#home">Hem</a></li>
<li><a href="#contact">Kontakt</a></li>
<li><a href="#gallery">Galleri</a></li>
<li><a href="#tickets">Turnéplan</a></li>
<li><a href="#music" class="active">Vår musik</a></li>
</ul>
</nav>
<!-- Introvideo -->
<div class="hero">
<video autoplay muted loop playsinline>
<source src="video.mp4" type="video/mp4">
</video>
</div>
<!-- Sidfot -->
<footer>
<div>
<p>Digital Symphony Autumn Tour -25</p>
</div>
<div>
<p>Kontakt: [email protected]</p>
</div>
</footer>
</body>
</html>

html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
font-family: "Orbitron", sans-serif;
background-color: #0D0D0D;
background-image: url(bakgrundsbild1.jpg);
background-size: cover;
background-repeat: no-repeat;
display: flex;
flex-direction: column;
}
/* Typsnitt */
.press-start-2p-regular {
font-family: "Press Start 2P", system-ui;
font-weight: 400;
font-style: normal;
}
/* Meny */
.navigation {
background-color: #0D0D0D;
padding: 1em 0;
overflow: hidden;
width: 100%;
position: relative;
z-index: 1;
margin-bottom: -10px; /* Justera eventuellt för att eliminera mellanrummet */
}
.navigation ul {
list-style: none;
padding: 0;
margin: 0;
display: flex;
justify-content: flex-end;
}
.navigation li {
margin: 0 1em;
}
.navigation li:first-child {
margin-right: auto;
}
.navigation a {
text-decoration: none;
color: #FF6EC7;
padding: 1em;
display: block;
}
.navigation a:hover,
.navigation a.active {
background-color: #FFD700;
color: #FF6EC7;
border-radius: 0.8em;
}
/* Introvideo */
.hero {
position: relative;
width: 100%;
height: calc(100vh - 60px); /* Justera eventuellt höjden beroende på navigationens höjd */
overflow: hidden;
margin-top: -10px; /* Justera eventuellt för att eliminera mellanrummet */
}
video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
transform: translate(0, 0);
}
/* Footer */
footer {
background-color: #0D0D0D;
color: #FF6EC7;
padding: 1em;
text-align: center;
margin-top: auto;
}
 
Change your video css to ONLY this:

video {
width: 100%;
height: auto;
}

For the text over video:

<div class="hero">
<div class="textovervideo"><p>Here I am!</p></div>
<video autoplay muted loop playsinline>
<source src="video.mp4" type="video/mp4">
</video>
</div>

.textovervideo{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
z-index: 5;
}
.textovervideo p{
font-size: 2em;
color: #FF6EC7;
text-shadow: 0.1em 0.1em 0.2em #000;
font-family: "Press Start 2P", system-ui;
}
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom