Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Elementos passando sobre header fixo!!

Pessoal,

Estou fazendo uma pagina para treino e encontrei um problema, criei um menu fixo, e alguns elementos estão passando por cima do meu menu. Não sei como corrigir. Fico aberto a qualquer dica extra sobre o projeto a baixo.

<!DOCTYPEhtml>
<html>

<head>
    <title>Honda Civic G10</title>
    <meta charset="utf-8">
    <meta name="author" content="Rayan, Luan, Vinicius e Gian">
    <link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Armata" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
    <div class="header_background"></div>
    <header>
        <nav>
            <img src="Honda-Logo-PNG.png" alt="Foto do logo Honda">

            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">Design</a></li>
                <li><a href="#">Modelos</a></li>
                <li><a href="#">Especs</a></li>
                <li><a href="#">Lojas</a></li>
                <li><a href="#">Contato</a></li>
            </ul>
        </nav>
    </header>

<aside class="title-header">
    <p>Desing e Conforto em um só carro</p>
</aside>

<div class="design-section">
    <h2>Design e Features</h2>
    <div>
        <img src="Civic_sport_full_galeria_7.jpeg" alt="Foto interior do Honda Civic">
        <img src="Civic_sport_full_galeria_6.jpg" alt="Foto interior do Honda Civic">
        <img src="Civic_sport_full_galeria_5.jpg" alt="Foto interior do Honda Civic">
        <img src="Civic_sport_full_galeria_4.jpg" alt="Foto interior do Honda Civic">
        <img src="Civic_sport_full_galeria_3.jpg" alt="Foto interior do Honda Civic">
        <img src="Civic_sport_full_galeria_2.jpg" alt="Foto interior do Honda Civic">
        <img src="Civic_sport_full_galeria_1.jpg" alt="Foto interior do Honda Civic">
    </div>
</div>

</body>

</html>
*{
    margin: 0;
    padding: 0;
}

header img {
    width: 80px;
    margin-left: 3%;
    padding: 1.5em;
    float: left;

}

header {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    position: fixed;
    top: 0;
}

.header_background  {
    background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url(header_index.jpg);
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
    height: 100vh;
    box-shadow: 0 0 20px;
}

nav {
}

nav ul {
    float: left;
    width: 78%;
}

nav ul li {
    font-family: 'Quicksand', sans-serif;
    display: inline-block;
    font-size: 1.7em;
    margin-right: 2.5em;
    margin-top: 1.2em;
}

nav ul li:first-child {
    margin-left: 15%;
}

nav ul li a {
    text-decoration: none;
    color: #fff;
    font-weight: bold;
    text-shadow: 2px 2px 3px #000;
}

nav ul li a:hover {
    transition: 1s;
    color: rgb(232, 22, 22);
    text-shadow: 0 0 4px #000;
}

.title-header {
    font-family: 'Armata', sans-serif;
    font-size: 3em;
    color: #FFF;
    text-shadow: 2px 2px 2px #000;
    position: absolute;
    width: 30%;
    top: 38%;
    left: 6%;
    z-index: 1;
}

.design-section {
    width: 90%;
    margin: auto;
}



.design-section img {
    width: 21%;
    margin: 0.9em;
    border: 1.5px solid #525252;
    float: left;
}

.design-section img:first-of-type {
    width: 45%;
}

/*--------------------------EFEITO GALERIA--------------------*/

.design-section div img:hover,
.design-section div  img:focus {
    transform: scale(4);
    box-shadow: 0 0 0 99999px rgba(0, 0, 0, 0.5);
    transition: 1s;

}

.design-section div img:hover,
.design-section div img:focus:first-of-type {
    transform: scale(1.3);
}


/*--------------------------FIM EFEITO-------------------------*/

.design-section h2 {
    font-size: 2.5em;
    margin: 1.5em;
    text-align: center;
    text-shadow: 2px 2px 3px #666;
    text-transform: uppercase;
}
2 respostas
solução!

Olá Rayan, faltou definir o z-index do seu menu, ele controla a "profundidade" (eixo Z) dos elementos.

header {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    position: fixed;
    top: 0;
    z-index: 99;  
}

Você pode ver mais sobre a propriedade no link abaixo: https://css-tricks.com/almanac/properties/z/z-index/

Obrigado, Vegara. Eu havia tentado z index, antes mas não consegui, talvez estava colocando no seletor errado.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software