Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

73
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda