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
- Add a border to
.inner
element: 1px, solid, black - center the element horizontally
- with a fixed width of 400px
- without a fixed width
There are different solutions to this exercise, some work with both constraints, some only work with just one constraint
Template
Solution 1 (only works with fixed width)
Linkcss-positioning.ex1.solution1.html
Solution 2 (works with and without fixed width)
Linkcss-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
- Add a border to
.inner
element: 1px, solid, black - Implement different solutions
- with absolute/relative positioning
- with flex layout
- with grid layout
Template
Solution 1: absolute layout
Linkcss-positioning.ex2.solution1.html
Solution 1: Flex Layout
Linkcss-positioning.ex2.solution2.html
Solution 1: Grid Layout
Linkcss-positioning.ex2.solution3.html