0
I have the following HTML code that for some reason the tag <h1 class="teste">
is not recognizing the elements that are above it and tries to occupy the same space as the header
on the screen, you end up hiding below the header.
$(document).ready(function() {
$('.open-nav').click(function() {
$('.menu').toggleClass('active');
})
})
* {
box-sizing: border-box;
transition: all .3s ease;
}
.teste {
color: red;
}
html,
body {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
}
ul {
list-style: none;
}
.container {
width: 100%;
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
header {
position: fixed;
width: 100%;
top: 0;
left: 0;
background-color: black;
border-bottom: 1px solid grey;
}
.content-header {
display: flex;
align-items: center;
justify-content: space-between;
}
.open-nav {
display: none;
}
nav {
width: 100%;
max-width: 700px;
}
nav .list-menu {
display: flex;
justify-content: space-between;
align-items: center;
}
nav .list-menu a {
position: relative;
text-decoration: none;
color: white;
text-transform: uppercase;
padding: 5px;
}
nav .list-menu a:hover {
color: grey;
}
nav .list-menu a::before {
content: '';
position: absolute;
width: 0;
height: 2px;
left: 0;
bottom: 0;
background-color: white;
transition: all .3s ease;
}
nav .list-menu a:hover::before {
width: 100%;
transition: all .3s ease;
}
<!DOCTYPE html5>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="style/style.css" rel="stylesheet">
<title>Futher Store</title>
</head>
<body>
<header class="header-side">
<div class="container">
<div class="content-header">
<img src="image/logotipo-futher.jpg" alt="logotipo-futher-urso" class="logotipo-futher">
<button class="open-nav">
<span class="line line_1"></span>
<span class="line line_2"></span>
<span class="line line_3"></span>
</button>
<nav class="menu">
<ul class="list-menu">
<li><a href="#">Home</a></li>
<li><a href="#">Sobre</a></li>
<li><a href="#">Produtos</a></li>
<li><a href="#">Medias</a></li>
</ul>
</nav>
</div>
</div>
</header>
<h1 class="teste">TESTANDO</h1>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="js/script.js"></script>
</body>
</html>
Yes, header position: Fixed causes the space it would occupy to be ignored by the other elements.
– bfavaretto