Lecture 7_Internet Technology & Web Design
Lecture 7_Internet Technology & Web Design
CSS Layout
Introduction
In the previous lecture, we explored techniques for arranging CSS boxes within the viewport and
in relation to other elements, covering display settings and various positioning methods. We also
introduced Flexbox, a powerful modern layout tool for creating flexible, responsive designs. In
this lecture, we will delve further into Flexbox, exploring its core concepts and features in
greater detail to provide a comprehensive understanding of how to use it effectively for layout
design.
FLEX BOX
A Flex box (Flexible Box) is a layout model designed to help arrange items within a container
efficiently and responsively. It provides a way to distribute space along a single axis (either
horizontal or vertical) and adjust the size of items to fill available space or shrink to prevent
overflow. The horizontal axis is called the Main Axis while the vertical is called the Cross Axis.
Flexbox breaks the old style of using float or position making it easier to design flexible
responsive layout page structures.
In the following code, we have a flex-container (the parent div) and 3 div container elements (the
children div). https://www.w3schools.com/css/tryit.asp?filename=trycss3_flexbox
The flex container becomes flexible when by setting the display property to flex.
The example uses a child combinator selector to style the flex items.
https://www.w3schools.com/css/css_combinators.asp
● flex-direction
● flex-wrap
● flex-flow
● justify-content
● align-items
● align-content
The flex-wrap property specifies whether the flex items should wrap or not. We wrap by setting
flex-wrap to wrap.
Example:
https://www.w3schools.com/css/tryit.asp?filename=trycss3_flexbox_flex-wrap_wrap
2.1 Removing the wrap:
We set flex-wrap to nowrap to specify that the flex items will not wrap. This is ideally the default
setting.
Example:
https://www.w3schools.com/css/tryit.asp?filename=trycss3_flexbox_flex-wrap_nowrap
2.2 Reversing the wrap order:
To specify the flexible items wraps in reverse order, we set flex-wrap to wrap-reverse.
Example:
https://www.w3schools.com/css/tryit.asp?filename=trycss3_flexbox_flex-wrap_wrap-reverse
Property Description
Conclusion
To this extent, we have explored how to manipulate the flex container (parent). In the next
lecture, we shall explore the flex items (the child elements) and the different properties used.
Check Next Topic: https://www.w3schools.com/css/css3_flexbox_items.asp