← back

CSS Positioning

In this exercise you learn some tricks for css positioning together with different layout types

Exercise 1: horizontal positioning

Use the template provided here: Template and a solution on how to center an element

There are different solutions to this exercise, some work with both constraints, some only work with just one constraint

Possible layout of the page

Template

Solution 1 (only works with fixed width)

Link
css-positioning.ex1.solution1.html

            

Solution 2 (works with and without fixed width)

Link
css-positioning.ex1.solution2.html

            

Exercise 2: horizontal and vertical positioning

Use the template provided here: Template and a solution on how to center an element

Possible layout of the page

Template

Solution 1: absolute layout

Link
css-positioning.ex2.solution1.html

            

Solution 1: Flex Layout

Link
css-positioning.ex2.solution2.html

            

Solution 1: Grid Layout

Link
css-positioning.ex2.solution3.html