{"id":947,"date":"2023-03-23T08:25:03","date_gmt":"2023-03-23T08:25:03","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/?page_id=947"},"modified":"2023-03-30T16:13:31","modified_gmt":"2023-03-30T15:13:31","slug":"css-flex-and-grid","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/authoring-a-website\/week-2\/css-flex-and-grid\/","title":{"rendered":"CSS Flex and grid"},"content":{"rendered":"\n<p>CSS3 brings two useful methods for creating designs that work on varying resolutions of screen.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Flex<\/h2>\n\n\n\n<p>Flex allows you to define how elements will be arranged inside a container. Do you want them stacked in a column, or going horizontally. Do they gather to the left, right or spaced evenly.<\/p>\n\n\n\n<p>As the size of the container changes, the sub items will rearrange to fit.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Grid<\/h2>\n\n\n\n<p>Grid allows you to split an area up into rows and columns. This is useful for making the layout of a page or a section of it.<\/p>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Flex<\/h2>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;title&gt;Flex Test&lt;\/title&gt;\n  &lt;style&gt;\n    .flexbox-container {\n      display: flex;\n      flex-direction: row;\n      flex-wrap: wrap;\n    }\n    .flexbox-container div {\n      background-color: #8888ff;\n      border: 1px solid black;\n      margin: 5px;\n      font-size: 4rem;\n      width: 15em;\n      height: 5em;\n    }\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;div class=\"flexbox-container\"&gt;\n    &lt;div&gt;1&lt;\/div&gt;\n    &lt;div&gt;2&lt;\/div&gt;\n    &lt;div&gt;3&lt;\/div&gt;\n  &lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>Try changing the direction and wrap rules to see how the display changes. <\/p>\n\n\n\n<p>There are further options. For example, flex-direction can also use row-reverse and column-reverse for values. Flex-wrap can be set to wrap-reverse if you wanted the extra items to wrap to lines above the original.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Here we define a div to be the container by using the <strong>display: flex<\/strong> property. We use <strong>flex-direction: row<\/strong> to tell the browser to show the sub items of the contain in a horizontal row. We could have used <strong>flex-direction: column<\/strong> if you wanted them stacked vertically on top of each other. We use <strong>flex-wrap: wrap<\/strong> to say <em>&#8220;When you can&#8217;t fit all the elements on one line, wrap them onto another one&#8221;<\/em>. If you wanted to force them onto a line you could use <strong>flex-wrap: nowrap<\/strong>.<\/p>\n\n\n\n<p>You can ignore all the properties on the the child items as that&#8217;s just to make them more visible for the demonstration.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"355\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23084833\/flex1-1024x355.png\" alt=\"Flex items on a wide display\" class=\"wp-image-955\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23084833\/flex1-1024x355.png 1024w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23084833\/flex1-300x104.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23084833\/flex1-768x266.png 768w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23084833\/flex1.png 1260w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Flex items on a wide display<\/figcaption><\/figure><\/div>\n\n\n\n<p>If we look at the same code on a display that can only fit one of the child items into the contain on a row they automatically stack.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23084939\/flex2.png\" alt=\"Flex items on a narrow display\" class=\"wp-image-956\" width=\"317\" height=\"460\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23084939\/flex2.png 634w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23084939\/flex2-207x300.png 207w\" sizes=\"auto, (max-width: 317px) 100vw, 317px\" \/><figcaption>Flex items on a narrow display<\/figcaption><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<p>If you want to use a percentage of the flex container you could use the <strong>flex-basis<\/strong> property on the child elements. So 2 equal columns could use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.flexbox-container {\r\n  display: flex;\r\n  flex-direction: row;\r\n  flex-wrap: wrap;\r\n}\r\n.flexbox-container &gt; div {\r\n  flex-basis: 50%;\r\n}<\/code><\/pre>\n\n\n\n<p>Each child div would take up 50% of the width of the parent.<\/p>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Justify-content<\/h3>\n\n\n\n<p>justify-content aligns the items within the container. By default it puts all the items to the left, unless you are using a flex-direction of row-reverse. But it can have the values:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">flex-start<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"171\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085744\/flex-start-1024x171-1.png\" alt=\"Example of justify-content: flex-start\" class=\"wp-image-963\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085744\/flex-start-1024x171-1.png 1024w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085744\/flex-start-1024x171-1-300x50.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085744\/flex-start-1024x171-1-768x128.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption> Example of justify-content: flex-start<\/figcaption><\/figure><\/div>\n\n\n\n<p>All the child elements are aligned to the left side of the container, or right on row-reverse.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">flex-end<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"171\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085713\/flex-end-1024x171-1.png\" alt=\"Example of justify-content: flex-end\" class=\"wp-image-962\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085713\/flex-end-1024x171-1.png 1024w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085713\/flex-end-1024x171-1-300x50.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085713\/flex-end-1024x171-1-768x128.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption> Example of justify-content: flex-end<\/figcaption><\/figure><\/div>\n\n\n\n<p>All the child elements are aligned to the right side of the container, or left for row-reverse.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">center<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"173\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085613\/center-1024x173-1.png\" alt=\"Example of justify-content: center\" class=\"wp-image-961\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085613\/center-1024x173-1.png 1024w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085613\/center-1024x173-1-300x51.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085613\/center-1024x173-1-768x130.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Example of justify-content: center<\/figcaption><\/figure><\/div>\n\n\n\n<p>All the child elements are aligned in the center of the container.<\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">space-around<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"172\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085823\/space-around-1024x172-1.png\" alt=\"Example of justify-content: space-around\" class=\"wp-image-964\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085823\/space-around-1024x172-1.png 1024w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085823\/space-around-1024x172-1-300x50.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085823\/space-around-1024x172-1-768x129.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption> Example of justify-content: space-around<\/figcaption><\/figure><\/div>\n\n\n\n<p>The container works out how many will fit on a row and then divides the width available between the child elements then centre aligns each element in its own section.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">space-between<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"171\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085854\/space-between-1024x171-1.png\" alt=\"Example of justify-content: space-between\" class=\"wp-image-965\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085854\/space-between-1024x171-1.png 1024w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085854\/space-between-1024x171-1-300x50.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23085854\/space-between-1024x171-1-768x128.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption> Example of justify-content: space-between<\/figcaption><\/figure><\/div>\n\n\n\n<p>The container works out how many will fit on a row and then puts one to the far left, one to the far right, and the rest are equally spaced between.<\/p>\n<\/div>\n<\/div>\n\n\n\n<p>Add a justify-content property to your container. Choose whichever value you want.<\/p>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Align-content<\/h3>\n\n\n\n<p>This property controls how the child items are vertically aligned within the container if the container is taller than the items. By default it puts all the items to the top. It can have the values:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">flex-start<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"770\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092055\/flex-start3.png\" alt=\"An example of align-content: flex-start\" class=\"wp-image-970\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092055\/flex-start3.png 1000w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092055\/flex-start3-300x231.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092055\/flex-start3-768x591.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption>An example of align-content: flex-start<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">flex-end<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"774\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092120\/flex-end3.png\" alt=\"An example of align-content: flex-end\" class=\"wp-image-971\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092120\/flex-end3.png 1000w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092120\/flex-end3-300x232.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092120\/flex-end3-768x594.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption> An example of align-content: flex-end<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">center<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"769\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092138\/center3.png\" alt=\"An example of align-content: center\" class=\"wp-image-972\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092138\/center3.png 1000w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092138\/center3-300x231.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092138\/center3-768x591.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption> An example of align-content: center<\/figcaption><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">space-around<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"770\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092212\/space-around2.png\" alt=\"An example of align-content: space-around\" class=\"wp-image-973\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092212\/space-around2.png 1000w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092212\/space-around2-300x231.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092212\/space-around2-768x591.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption> An example of align-content: space-around <\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">space-between<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"771\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092243\/space-between2.png\" alt=\"An example of align-content: space-between\" class=\"wp-image-974\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092243\/space-between2.png 1000w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092243\/space-between2-300x231.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092243\/space-between2-768x592.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption> An example of align-content: space-between<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">stretch<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"769\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092323\/stretch2.png\" alt=\"An example of align-content: stretch\" class=\"wp-image-975\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092323\/stretch2.png 1000w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092323\/stretch2-300x231.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23092323\/stretch2-768x591.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption> An example of align-content: stretch<\/figcaption><\/figure><\/div>\n\n\n\n<p>Stretch will only be apparent if you haven&#8217;t set a height property for the child elements.<\/p>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Grid<\/h2>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;title&gt;Grid Test&lt;\/title&gt;\n  &lt;style&gt;\n\n    body {\n      margin: 0;\n    }\n    .grid-container {\t\n      display: grid;\n      grid-template-columns: auto auto auto;\n    }\n    .grid-item {\n      background-color: #8888ff;\n      border: 1px solid black;\n      margin: 2px;\n      height: 5em;\n    }\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;div class=\"grid-container\"&gt;\n  &lt;div class=\"grid-item\"&gt;1&lt;\/div&gt;\n  &lt;div class=\"grid-item\"&gt;2&lt;\/div&gt;\n  &lt;div class=\"grid-item\"&gt;3&lt;\/div&gt;\n&lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Here we define a div to be our grid container using <strong>display: grid<\/strong>, we then use the <strong>grid-template-columns: auto auto auto<\/strong> to set the grid to have 3 equally sized colums.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"44\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23093606\/grid1-1-1024x44.png\" alt=\"Example of grid with 3 even columns\" class=\"wp-image-978\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23093606\/grid1-1-1024x44.png 1024w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23093606\/grid1-1-300x13.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23093606\/grid1-1-768x33.png 768w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23093606\/grid1-1.png 1260w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Example of grid with 3 even columns<\/figcaption><\/figure>\n\n\n\n<p>Maybe we want to use this grid for a layout and have a large centre area and different sizes on each side. Instead of using auto auto auto we can set sizes<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grid-template-columns: 25vw 70vw 5vw;<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"42\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23093735\/grid2-1024x42.png\" alt=\"Example of grid with 3 uneven columns\" class=\"wp-image-979\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23093735\/grid2-1024x42.png 1024w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23093735\/grid2-300x12.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23093735\/grid2-768x32.png 768w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23093735\/grid2.png 1260w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Example of grid with 3 uneven columns<\/figcaption><\/figure><\/div>\n\n\n\n<p>A really useful new size unit for grids is fr which stands for fraction of the available space. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grid-template-columns: 1fr 2fr;<\/code><\/pre>\n\n\n\n<p>In the above the 2nd column will be twice the width of the 1st column. And fr ignores any space set aside for gaps between columns.<\/p>\n\n\n\n<p>How to change the number of columns? Change the number of values in the grid-template-column property. So 5 equal columns would be:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grid-template-columns: auto auto auto auto auto;<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p>If you want to control the rows rather than columns then it follows the same pattern. Just use the <strong>grid-template-rows<\/strong> property instead.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code\"><code>grid-template-rows: 200px 100px 50px;<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"925\" height=\"917\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094052\/33.png\" alt=\"Example of grid-template-rows\" class=\"wp-image-982\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094052\/33.png 925w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094052\/33-300x297.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094052\/33-150x150.png 150w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094052\/33-768x761.png 768w\" sizes=\"auto, (max-width: 925px) 100vw, 925px\" \/><figcaption>Example of grid-template-rows<\/figcaption><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Justify-content<\/h3>\n\n\n\n<p>If the items don\u2019t take up the full width of the container then you can use the justify-content property to change how they are arranged:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">space-evenly<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"925\" height=\"907\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094457\/justify-even.png\" alt=\"Example of justify-content: space-evenly\" class=\"wp-image-986\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094457\/justify-even.png 925w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094457\/justify-even-300x294.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094457\/justify-even-768x753.png 768w\" sizes=\"auto, (max-width: 925px) 100vw, 925px\" \/><figcaption>Example of justify-content: space-evenly<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">space-around<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"927\" height=\"908\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094436\/justify-around.png\" alt=\"Example of justify-content: space-around\" class=\"wp-image-985\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094436\/justify-around.png 927w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094436\/justify-around-300x294.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094436\/justify-around-768x752.png 768w\" sizes=\"auto, (max-width: 927px) 100vw, 927px\" \/><figcaption>Example of justify-content: space-around<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">space-between<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"924\" height=\"908\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094409\/justify-between.png\" alt=\"Example of justify-content: space-between\" class=\"wp-image-984\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094409\/justify-between.png 924w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094409\/justify-between-300x295.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094409\/justify-between-768x755.png 768w\" sizes=\"auto, (max-width: 924px) 100vw, 924px\" \/><figcaption>Example of justify-content: space-between<\/figcaption><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">flex-start<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"921\" height=\"911\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094630\/justify-start.png\" alt=\"Example of justify-content: flex-start\" class=\"wp-image-989\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094630\/justify-start.png 921w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094630\/justify-start-300x297.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094630\/justify-start-768x760.png 768w\" sizes=\"auto, (max-width: 921px) 100vw, 921px\" \/><figcaption>Example of justify-content: flex-start<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">center<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"928\" height=\"907\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094610\/justify-center.png\" alt=\"Example of justify-content: center\" class=\"wp-image-988\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094610\/justify-center.png 928w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094610\/justify-center-300x293.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094610\/justify-center-768x751.png 768w\" sizes=\"auto, (max-width: 928px) 100vw, 928px\" \/><figcaption>Example of justify-content: center<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">flex-end<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"924\" height=\"907\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094546\/justify-end.png\" alt=\"Example of justify-content: flex-end\" class=\"wp-image-987\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094546\/justify-end.png 924w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094546\/justify-end-300x294.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23094546\/justify-end-768x754.png 768w\" sizes=\"auto, (max-width: 924px) 100vw, 924px\" \/><figcaption>Example of justify-content: flex-end<\/figcaption><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Align-content<\/h3>\n\n\n\n<p>If the items don\u2019t take up the full height of the container then you can use the align-content property to change how they are vertically arranged:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">space-evenly<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"924\" height=\"907\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095100\/align-evenly.png\" alt=\"Example of align-content: space-evenly\" class=\"wp-image-993\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095100\/align-evenly.png 924w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095100\/align-evenly-300x294.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095100\/align-evenly-768x754.png 768w\" sizes=\"auto, (max-width: 924px) 100vw, 924px\" \/><figcaption>Example of align-content: space-evenly<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">space-around<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"928\" height=\"914\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095040\/align-around.png\" alt=\"Example of align-content: space-around\" class=\"wp-image-992\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095040\/align-around.png 928w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095040\/align-around-300x295.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095040\/align-around-768x756.png 768w\" sizes=\"auto, (max-width: 928px) 100vw, 928px\" \/><figcaption>Example of align-content: space-around<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">space-between<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"925\" height=\"905\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095018\/align-between.png\" alt=\"Example of align-content: space-between\" class=\"wp-image-991\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095018\/align-between.png 925w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095018\/align-between-300x294.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095018\/align-between-768x751.png 768w\" sizes=\"auto, (max-width: 925px) 100vw, 925px\" \/><figcaption>Example of align-content: space-between<\/figcaption><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">flex-start<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"924\" height=\"907\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095133\/align-start.png\" alt=\"Example of align-content: flex-start\" class=\"wp-image-994\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095133\/align-start.png 924w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095133\/align-start-300x294.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095133\/align-start-768x754.png 768w\" sizes=\"auto, (max-width: 924px) 100vw, 924px\" \/><figcaption>Example of align-content: flex-start<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">center<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"927\" height=\"911\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095158\/align-center.png\" alt=\"Example of align-content: center\" class=\"wp-image-995\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095158\/align-center.png 927w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095158\/align-center-300x295.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095158\/align-center-768x755.png 768w\" sizes=\"auto, (max-width: 927px) 100vw, 927px\" \/><figcaption>Example of align-content: center<\/figcaption><\/figure><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\">flex-end<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"927\" height=\"916\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095226\/align-end.png\" alt=\"Example of align-content: flex-end\" class=\"wp-image-996\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095226\/align-end.png 927w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095226\/align-end-300x296.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095226\/align-end-768x759.png 768w\" sizes=\"auto, (max-width: 927px) 100vw, 927px\" \/><figcaption>Example of align-content: flex-end<\/figcaption><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Gaps<\/h3>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>What if your grid items take up the full size but you still want a space between each. Use a gap property.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>column-gap<\/li><li>row-gap<\/li><li>gap (this is just shorthand for row-gap and column-gap together)<\/li><\/ul>\n\n\n\n<p>For example the image to the right has a column-gap of 40px and a row-gap of 10px. This could be done as:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gap: 10px 40px;<\/code><\/pre>\n\n\n\n<p>Or as:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>column-gap: 40px;\nrow-gap: 10px;<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"925\" height=\"909\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095401\/gap.png\" alt=\"Example of gaps\" class=\"wp-image-998\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095401\/gap.png 925w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095401\/gap-300x295.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23095401\/gap-768x755.png 768w\" sizes=\"auto, (max-width: 925px) 100vw, 925px\" \/><figcaption>Example of gaps<\/figcaption><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Grid items<\/h2>\n\n\n\n<p>Up until now all your styles have been applied to the container. But the items have options too:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>grid-column-start<\/li><li>grid-column-end<\/li><li>grid-column (shorthand for \u201cgrid-column-start \/ grid-column-end\u201d)<\/li><li>grid-row-start<\/li><li>grid-row-end<\/li><li>grid-row (shorthand for \u201cgrid-row-start \/ grid-row-end\u201d)<\/li><li>grid-area (shorthand for \u201cgrid-row-start \/ grid-column-start \/ grid-row-end \/ grid-column-end\u201d)<\/li><\/ul>\n\n\n\n<p>The grid-column property allows you to define the start and end columns of a child item within a grid.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;title&gt;Test&lt;\/title&gt;\n  &lt;style&gt;\n    .grid-container {\n      grid-template-columns: auto auto auto auto auto auto;\n      grid-template-rows: auto auto;\n      display: grid;\n      height: 600px;\n      width: 600px;\n      border: 1px solid black;\n    }\n    .grid-item {\n      background-color: #8888ff;\n      border: 1px solid green;\n      margin: 2px;\n    }\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;div class=\"grid-container\"&gt;\n    &lt;div class=\"grid-item\" style=\"grid-column: 1 \/ 4\"&gt;1&lt;\/div&gt;\n    &lt;div class=\"grid-item\" &gt;2&lt;\/div&gt;\n    &lt;div class=\"grid-item\" style=\"grid-column: 5 \/ 7\"&gt;3&lt;\/div&gt;\n    &lt;div class=\"grid-item\"&gt;4&lt;\/div&gt;\n    &lt;div class=\"grid-item\" style=\"grid-column: 2 \/ 6\"&gt;5&lt;\/div&gt;\n    &lt;div class=\"grid-item\"&gt;6&lt;\/div&gt;\n  &lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"925\" height=\"907\" src=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23100210\/grid-columns.png\" alt=\"Example of grid-columns\" class=\"wp-image-1002\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23100210\/grid-columns.png 925w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23100210\/grid-columns-300x294.png 300w, https:\/\/blogs.glowscotland.org.uk\/es\/public\/software\/uploads\/sites\/4063\/2023\/03\/23100210\/grid-columns-768x753.png 768w\" sizes=\"auto, (max-width: 925px) 100vw, 925px\" \/><figcaption>Example of grid-columns<\/figcaption><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<p>Here we have a grid made up of 2 rows and 6 columns. The first child item has a property of <strong>grid-column: 1 \/ 4<\/strong> which means <em>&#8220;start at column 1 and end at column 4&#8221;<\/em> in other words, start in the first column and span 3 columns. You can even write it that way.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grid-column: 1 \/ span 3;<\/code><\/pre>\n\n\n\n<p>The grid-row property works exactly the same. State in which row the item should and then say either where it ends or how many it spans.<\/p>\n\n\n\n<p>The grid-area property combines grid-row and grid-column. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grid-area: 1 \/ 2 \/ 3 \/ 4;<\/code><\/pre>\n\n\n\n<p>grid-row-start is set to the first value, grid-column-start is set to the second value, grid-row-end is set to the third value, and grid-column-end is set to the fourth value. So this would be the same as:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grid-row: 1 \/ 3;\ngrid-column: 2 \/ 4;<\/code><\/pre>\n\n\n\n<p class=\"nextlink\"><a href=\"https:\/\/blogs.glowscotland.org.uk\/es\/software\/authoring-a-website\/\" data-type=\"page\" data-id=\"52\">End of the week<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSS3 brings two useful methods for creating designs that work on varying resolutions of screen. Flex Flex allows you to define how elements will be arranged inside a container. Do you want them stacked in a column, or going horizontally. Do they gather to the left, right or spaced evenly. As the size of the&hellip; <a class=\"more-link\" href=\"https:\/\/blogs.glowscotland.org.uk\/es\/software\/authoring-a-website\/week-2\/css-flex-and-grid\/\">Continue reading <span class=\"screen-reader-text\">CSS Flex and grid<\/span><\/a><\/p>\n","protected":false},"author":5710,"featured_media":0,"parent":56,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-947","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/wp-json\/wp\/v2\/pages\/947","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/wp-json\/wp\/v2\/users\/5710"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/wp-json\/wp\/v2\/comments?post=947"}],"version-history":[{"count":26,"href":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/wp-json\/wp\/v2\/pages\/947\/revisions"}],"predecessor-version":[{"id":1130,"href":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/wp-json\/wp\/v2\/pages\/947\/revisions\/1130"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/wp-json\/wp\/v2\/pages\/56"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/es\/software\/wp-json\/wp\/v2\/media?parent=947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}