For some time, many CSS developers have kept integrating CSS grid layout specifications into actual projects. This is because there is no time to invest in specification variability, insufficient browser support, or learning new layout techniques. Now, since the grid layout is in the safe stage of use in most projects, I hope this CSS grid layout tutorial will be helpful if the CSS function has not been fully checked. Similar to our previous flexbox tutorials, this CSS grid layout tutorial will include specific interactive demonstrations that demonstrate many of the features of the grid layout specification. The
Directory: why use CSS grid layout# CSS grid layout terminology definitions \container grid layout properties \grid container settings: display:grid:template rows and grid template columns \fr define row and column sizes in units \specify named grid areas: grid template areas \implicitly defined grid tracks: grid auto rows and grid auto columns \grid items Automatic sorting: grid auto flow \grid layout properties of grid projects \grid project placement grid row start\/end and grid column start\/end \named grid lines \general sorting properties \grid simplification properties \other CSS grid layout functions \\\beginners \developer’s Guide: CSS grid layout tutorial with interactive examples Why use face click CSS grid layout? Before looking at specific examples of various attributes and values related to grid layout, let’s take a brief look at the problems to be solved by grid layout. Specifications are as follows: The
Grid layout provides a mechanism that allows authors to divide the available space in a layout into columns and rows using a predictable set of scaling actions. Male flexbox is easier to operate than using float or positioning techniques, but grid layout allows you to control the layout of grid format more finely. Over the years, people who design prototypes or use CSS grid frameworks have become accustomed to such work. Another advantage of grid is also described in the specification. Grid layouts allow you to dramatically transform the visual layout structure without making corresponding dimensional changes. The
CSS grid layouts can easily cover projects and have the same extended functionality as when creating table based layouts a few years ago. Most importantly, with a grid layout, you can easily build a regular design, such as a two column layout, with minimal code. With this in mind, let’s take a look at properties and values to understand the core of this CSS grid layout tutorial. Top mobile CSS grid layout term definitions this specification uses multiple terms to help understand different aspects of grid layout and how grid projects work. The key terms you want to remember in this CSS grid tutorial are: The
Grid container – set the grid and drag the elements of the grid item grid item – sub element grid lines inside the grid container – separate the horizontal and vertical grid tracks of the grid – all grid columns or rows (that is, between grid lines) Grid cells – a single cell grid area (such as a table where columns and rows intersect) – a rectangular area of one or more cells (consisting of 4 grid lines) some of the above terms will be used in the next section, so keep this term in mind when presenting and coding. When learning the grid layout properties of the top mobile container different parts of the grid layout specification, the grid container
It is useful to remember the functions of and grid items. The
This CSS grid tutorial will first introduce the properties to be applied to the grid container. Including: Set the mobile grid container at the top of the grid template rows grid template columns grid template area: similar to display:grid flexbox, the main function of activating the grid layout function is to use specific values of display attributes. Grid container {display: grid;} Code language: use CSS (CSS) corresponding code. The grid container element has the following properties: The
Creates a grid format context. Projects in the grid become grid projects (similar to the concept of \
Define the top moving grid: after the grid template rows and grid template columns grid containers are prepared, the rows and columns of the grid must be defined. The grid template rows and grid template columns attributes define two levels. A simple example of using the size (column or row) of a grid track (optional) row name (described in detail later) PX length instead of row name is as follows: Container {display: grid; grid template rows: 120px 120px; grid template columns: 400px 100px 194px;} Code language: CSS (CSS) this code instructs the browser to render the following: The
The two rows with a height of 120px and the four columns with a width of 400px, 100px, 100px and 194px are deliberately abnormal and specific, so they are not ideal. However, it serves to illustrate how to define rows and columns. The following demonstration will demonstrate this. Both properties allow keyword values for none (default) and auto, as well as the following functions and keywords: Fit content() minmax (min, max) – defines the size range of rows or columns. Maxcontent mincontent may be interested in the following items: Free WordPress and Beaver builder methods for building login pages WordPress sites must have reasons for fixed UI elements and methods for creating Wix tutorials: step by step guide for beginners to use Wix move fr units at the top, also known as flexible length values for defining row and column sizes. Fr units are grid templated rows and grid templatetemplate- One of the more useful units of the columns property. The
As you can see from the name, FR units represent a portion of the remaining space in the grid container. Here is an example Container {display: grid; grid template rows: 1.5 FR 1 fr; grid template columns: 3.4 FR 1 FR 1 fr 2 Fr;} Code language: similar to the example before CSS (CSS), it is again linked to two lines
Here we go. If a negative value is used, the grid lines are calculated in reverse. All of these are reversed to horizontal and \/ or vertical in different write modes. All grid placement attributes allow auto or one of the following values: Custom identifiers that match non-zero positive or negative integer named grid lines (specify later named grid lines) are combined with space separated above two value identifiers and integers, followed by two grid items (item 1 and item 11) after the keyword span Several sample codes for specifying as targets. Item: nth child (1) {grid row start: 1; grid row end: 3; grid column start: 1; grid column end: 4;} Item: nth child (11) {grid column start: 2; grid column end: 4; grid row start: 4; grid row end: 6;} Code language: the next interactive demonstration of CSS will help you understand how the above code works. Note and understand where grid line numbering begins and ends (see Figure). The span keyword is used with integers to indicate that grid items \