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

72
Visualizações
ReactJs with media queries

I'm developing a a base site app for a multi-function site. So in this moment I'm developing only the responsive frame where the app will go. I want the page to have a header and 3 columns (2 lateral columns for ads and a middle column for the application). I want the lateral columns to appear only in resolutions above 850px. So I have the following code:

App.js:

<...imports, etc ...>
function App() {
    return (
        <Router>
            <Navbar />
            <div className='divAds'>
                <VerticalAd />
                <div className='divMiddle' >
                    <HorizontalAd />
                    <div className="App" >
                        <Switch>
                            <Route exact path="/" component={Main} />
                            <Route exact path="/about" component={About} />
                            <Redirect to="/" />
                        </Switch>
                    </div>
                </div>
                <VerticalAd />
            </div>
        </Router>
    )
}

and in VerticalAd component I have:

import React from 'react'
import VerticalSun from '../../img/sun-vert.jpg';
import { Image } from 'semantic-ui-react'
import './verticalAd.scss'

export const VerticalAd = () => (
    <div className='divVad'>
        <Image src={VerticalSun} rounded alt="Vertical Ad" />
        <Image src={VerticalSun} rounded alt="Vertical Ad" />
        <Image src={VerticalSun} rounded alt="Vertical Ad" />
    </div>

which created this page structure: Base page

So I want the lateral columns to disapear in mobile screens so I had the following css to VerticalAd.scss:

.divVad {
    @media (min-width: 850px) {
        display: block;
    }

    @media (max-width: 849px) {
        display: none;
    }
    
    img {
        width: 10em;
        height: 50em;
    }
}

But the vertical columns won't disapear in lower resolutions. What am I doing wrong ?

I tried to move @media queries to App.scss but didn't work also.

I'm testing this using Chrome developer tools's responsive test.

Edit

The problem was developer tools. ASAI tested it by sizing the whole browser window it worked. Sorry. But anyway... @Samathingamajig answer's was useful and I have accept it. Sorry any inconvenience.

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

0

You're writing the media queries the wrong way around; media queries go outside, selectors go inside:

.divVad {
    img {
        width: 10em;
        height: 50em;
    }
}

@media (min-width: 850px) {
    .divVad {
       display: block;
    }
}

@media (max-width: 849px) {
    .divVad {
       display: none;
    }
}
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