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

203
Vistas
White space appears after calling a Route even though height is set to 100vh

I have the following code, which works perfectly fine:

App.js

import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';

function App(){

    return (
        <Router>
            <div className="app">
                <SideBar/>
                <div className="my_app">
                    <NavBar/>

                    <Switch>
                        <Route path="/some/component" render={() => <SomeComponent/>}/>
                    </Switch>
                </div>

            </div>
        </Router>
                
    );
}

export default App;

App.scss:

*{
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}


.app{
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  background-color: rgb(247, 249, 252);
  display: flex;
}

.my_app{
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  background-color: rgb(247, 249, 252);
  display: flex;
  flex-flow: column;
}

Here is how the app looks BEFORE calling the SomeComponent Route: layout 1

Here is how the app looks AFTER calling the SomeComponent Route: layout after calling route

As you can see there is white space that appears after the SomComponent route is called, even though the app and my_app are both set to 100vh height.

I want the layout to readjust to fill the white space, after the SomeComponent route is called, how to fix that ?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can achieve that by using CSS Grid

Html:

<div class="app-layout">
   <div class="navbar"></div>
   <div class="sidebar"></div>
   <div class="route-view"></div>
</div>

Styles:

* {
    padding: 0;
    margin: 0;
}
.app-layout {
    width: 100vw;
    height: 100vh;
    overflow: hidden;


    display: grid;
    grid-template-columns: 250px 1fr;
    grid-template-rows: 50px  1fr;
    grid-template-areas: "navbar navbar"
                         "sidebar route-view";
}


.navbar {
    grid-area: navbar;
}
.sidebar {
    grid-area: sidebar;
}
.route-view {
    grid-area: route-view;
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

I fixed the issue of the App not stretching to accommodate for the items added by:

In App.scss:

I added:

overflow: auto;

ie:

.app{
  width: 100%;
  height: 100vh;
  .....
  overflow: auto;
}

.my_app{
  width: 100%;
  height: 100vh;
  .....
  overflow: auto;
}
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