html – CSS Grid doesn't fit horizontally when viewed on mobile-ThrowExceptions

Exception or error:

I’m trying to create a responsive layout where header and footer take around 5% of screen and are fixed. The mid section scrolls depending on number of elements in it. Even though I only mention fr and % values, the element sizes stay static irrespective of screen size changes. In firefox responsive mode (galaxy s9), I see vertical and horizontal scroll bars outside of the container class. Could someone point out what I might be doing wrong ?enter image description here

    <meta charset="UTF-8">
            grid-template-rows: 2fr 20fr 2fr;
            gap: 2px;
            background-color: lightblue
            display: grid;
            overflow: auto;
            grid-auto-flow: row;
            grid-auto-rows: 25%;
            gap: 2px;
            background-color: pink


    <div class='main'>
        <div class='header'>header here</div>
        <div class='container'>
            <div class="content">1</div>
            <div class="content">2</div>
            <div class="content">3</div>
            <div class="content">4</div>
            <div class="content">5</div>
        <div class='tapbar'>tap bar here</div>


Edit: Besides the selected answer, other mistake I was doing was not having html cover the entire area. Adding this to the style fixed it

    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
How to solve:

you just have to add the following meta tags in the head tag of your html page

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

Leave a Reply

Your email address will not be published. Required fields are marked *