While this tutorial has content that we believe is of great benefit to our community, we have not yet tested or edited it to ensure you have an error-free learning experience. It's on our list, and we're working on it! You can help us out by using the 'report an issue' button at the bottom of the tutorial.
With CSS grid layout, the grid itself within its container as well as grid items can be positioned with the following 6 properties: justify-items, align-items, justify-content, align-content, justify-self and align-self. These properties are part of the CSS box alignment module and they define a standard way to position elements with either flexbox or CSS grid.
- By default, maps map the grid point 0, 0 to the Game Maker world point 0, 0. But there are several functions available to change the map’s behaviour. To make the map align the grid in a rectangle, we can use the following function: glmapaligngridinrect(map, grid, rect, alignmenttype).
- A layout, indicated by an orange grid around the controls, helps you align controls horizontally and vertically to give the form a uniform appearance. This article shows you how to add, remove, or rearrange controls in layouts. In this article. Create a new layout. Switch a layout from tabular to stacked, or vice versa.
You can double-click on any of these items on the layer to open up the item properties. Tile layers are what you would expect, ie: a layer of images from a tile-set that are drawn to the room, but note that tiles in GameMaker Studio 2 are always snapped to the grid. Background layers can be a solid colour or can be generated from a sprite,.
Most of the alignment properties are applied on the grid container, but some are for grid items, for when you want to specify values that apply only for specific grid items. Let’s breakdown these properties and their effect one by one.
For the examples to follow, we’re using the following markup and CSS rules for our grid:
And here’s how our base grid looks like:
Properties on the Grid Container
justify-items
justify-items is used to justify the grid items along the row axis. The possible values are start, end, center and stretch. Here are examples with center and end:
align-items
Similar to justify-items, but aligns the grid items along the column axis:
For the following justify-content and align-content examples, our base styles differ a bit in order to be able to demonstrate a grid that’s smaller than its container:
justify-content
When the entire grid is smaller than the space for the grid container, use justify-content to justify the grid along the row axis. You can use the following values: start, end, center, stretch, space-around, space-between or space evenly:
align-content
Similar to justify-content, but align-content aligns the grid along the column axis:
Properties on the Grid Items
Both justify-self and align-self are analogous to the equivalent properties available on the container (justify-items and align-items), but they apply on specific items that should be positioned differently than the rest of the grid items.