Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

108
Visualizações
How to get @media(max-width 425px) to work alone, and not follow @media(max-width 768px)

I want to make responsive page using react JS. I have some problems making it. I don't really know how media query CSS works, but for @media(max-width:1024) and @media(max-width:768px) sizes it works as I expected. I guess for size @media (max-width:425px) will also work as where @media(max-width:768px) works. But apparently starting from @media(max-width:425px) it follows the previous breakpoint(@media(max-width:768px)) and @media(max-width:375px) following the @media(max-width:425px) style. At breakpoint 320px back to my expectations.

This is my html:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="index.css">
</head>

<body>
    <div class="container">
        This is content
    </div>
</body>

</html>

And this is my CSS code:

.container{
    background-color: red;
    height: 100vh;
}

@media(max-width:1024px){
    .container{
        background-color: yellow;
    }
}
@media(max-width:768px){
    .container{
        background-color: green;
    }
}
@media(max-width:425px){
    .container{
        background-color: blue;
    }
}
@media(max-width:375px){
    .container{
        background-color: rosybrown;
    }
}
@media(max-width:320px){
    .container{
        background-color: rosybrown;
    }
}

Is there a way for each breakpoint to take its own style. As in max-width:1024px which takes a yellow background and max-width:768px takes a green background. Is it possible if I want if at max-width:425px it takes a blue background and at max-width:375 it takes a rosybrown color. Thank you in advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try adding the only screen

@media(only screen and max-width:768px){
    .container{
        background-color: green;
    }
}

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda