Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!