1

My Page

In the above image, you can see track sizes are shown as I inspect the page, but as per my knowledge they are showing wrong track sizes.

For example, in the first row track size it is showing 150px.100px whereas as per my knowledge it should be 150px.900px as the total row width is 900px, because as my columns are divided into 400px, 300px, 200px in the grid.

Can you tell me where my misunderstanding is?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>CSS Grid</title>
    <style>
        *{
            box-sizing: border-box;
        }
        .container{
            border: 2px solid brown;
            display: grid;
            grid-template-columns: 400px 300px 200px;
            grid-template-rows: 150px 250px auto;
        }
        .item{
          border: 2px solid black;
          margin: 5px;
          height: 100px;
          width: 100px;
          background-color: yellow;
        }
        .item1{
            grid-row: 1/3;
        }
        .item2{

        }
        .item3{

        }
        .item4{

        }
        .item5{
            grid-row: 1/3;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="item item1">1</div>
        <div class="item item2">2</div>
        <div class="item item3">3</div>
        <div class="item item4">4</div>
        <div class="item item5">5</div>
    </div>
</body>
</html>

1
  • I don’t know for certain as I don’t know what your browser is actually showing, but it looks as though you are confusing vertical and horizontal. Commented May 19 at 5:22

1 Answer 1

2

The first numbers on each line's label is the size that is in your stylesheet, whilst the second is the computed size on your display - not the size of the whole row/column. The reason these don't match is because you probably have the scale of your display set above 100% (I think 125% is default on windows), you can change the size to 100% under display settings and you should see that the two values on each line match.

It looks like your screen has 150% scaling, so the computed value for the point you mentioned is calculated as 150/1.5 = 100. This is why you see 150px.100px. The whole browser window is also affected by this scaling, i.e: with 125% scaling, a 1920px by 1080px window will appear as an upscaled version of a 1536px by 864px window.

https://developer.chrome.com/docs/devtools/css/grid#track-sizes

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.