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

209
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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