Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 5431

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 61k
Author
Asked: November 27, 20242024-11-27T09:13:07+00:00 2024-11-27T09:13:07+00:00

Grid Layout in a nutshell

  • 61k

what is a grid ?
a grid is a 2-d structure of columns and rows . specifically a CSS grid consists of different blocks of html arranged in rows and columns. for example

<div class="grid-example">         <div class="grid-element-1">1</div>         <div class="grid-element-2">2</div>         <div class="grid-element-3">3</div>         <div class="grid-element-4">4</div>         <div class="grid-element-5">5</div>         <div class="grid-element-6">6</div>     </div> 
Enter fullscreen mode Exit fullscreen mode

here in the above html code grid-example is the name of the container class and grid-element-(1,2,3,4,5,6) are the elements of grid container. to arrange these element in the form of row and column there are plenty of properties used we can use them according to the layout of the page.
for example by using the basic grid template property I am going to generate a grid of 3 columns and 2 rows from the above html code.

       .grid-element-1{             background-color: black;             color: white;         }         .grid-element-2{             background-color: white;             color: black;         }         .grid-element-3{             background-color: black;             color: white;         }         .grid-element-4{             background-color: white;             color: black;         }         .grid-element-5{             background-color: black;             color: white;         }         .grid-element-6{             background-color: white;             color: black;         } 
Enter fullscreen mode Exit fullscreen mode

the above css generate the following pattern

Image description

now I am making this containers display grid see what happens . nothing much happens until we use the properties grid-template-columns.

.grid-example{             display: grid;             grid-template-columns: 100px 100px 100px;         } 
Enter fullscreen mode Exit fullscreen mode

Image description

you can see a 2*3 grid is generated having each block of 100px from the above code when it is added to the CSS file or entered in style tag .
grid-template-column is a property of the grid that specifies tracks in a grid columns how many and how much is their length is specified with grid-template-columns. similarly is the property of grid-template-rows that specifies tracks in row and their length .

Properties associated with grid

grid-tempelate-column
The grid-template-columns CSS property defines the line names and track sizing functions of the grid columns.
that is it defines the no. of columns in a grid and the size of each column in a grid . each individual column is a track on which html markup for different block is developed hence they are called tracks. for example

grid-template-columns: 160px 160px; 
Enter fullscreen mode Exit fullscreen mode

the above declaration of grid property generates two blocks of 160px each .
grid-template-columns: 1fr 60px;
the above declaration is same as the one which we used before it also generates the tracks in same way that is 2 in number but length of 1 track is 1fr that is total width of viewport minus the 60px of the second track .
fr here specifies a size unit dealing in fractions of width of the screen more prominently the viewport of the screen.
for example if i specify the tracks as

1fr 1fr 1fr 1fr

than it can be assumed all the tracks are of 1/4 the width of
viewport.

follow the link to mdn reference of the above property to learn more

grid-template-rows

The grid-template-rows property defines the height of each row.
everything is similar to the grid template column property from declaration to tracks of rows.

follow the link to mdn reference of the above property to learn more

gap
gap property is used to specify spacing between two or more grids elements. this is shorthand property for various grid gap properties combined together.

beginnerscsshtmlwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.