CSS Flexible Box Layout, commonly known as Flexbox, is a CSS web layout model that allows us easier distribution, and alignment, of items that is applied to.
By using CSS flexbox you have a ton of new attributes to apply to your CSS elements to make your layouts easier to accomplish and much more 'flexible' :)Â
But to start we must talk about the main axis, determined by the property of flex direction and the cross axis, this one runs perpendicular to the main axis.
This may sound a bit complex, but for people who are more visual for learning (like me) there are some resources that can help us understand the logic behind all this new language.
That is why I bring this post with information collected from a wonderful website that is giving me a light to understand what is all this fuss about flex box ... which no longer seems so terrible or crazy. This site is https://css-tricks.com/Â
Well, without more, I leave you a small sample about what I have read on this website, I really recommend you to visit the link to discover more interesting things about CSS and its tricks! Enjoy!
Since flexbox is a whole module and not a single property, it involves a lot of things including its whole set of properties. Some of them are meant to be set on the container (parent element, known as âflex containerâ) whereas the others are meant to be set on the children (said âflex itemsâ)
Properties for the Parent
(flex container)
This defines a flex container; inline or block depending on the given value. It enables a flex context for all its direct children.
This establishes the main-axis, thus defining the direction flex items are placed in the flex container. Flexbox is (aside from optional wrapping) a single-direction layout concept. Think of flex items as primarily laying out either in horizontal rows or vertical columns.
By default, flex items will all try to fit onto one line. You can change that and allow the items to wrap as needed with this property.
nowrap (default): all flex items will be on one line
wrap: flex items will wrap onto multiple lines, from top to bottom.
wrap-reverse: flex items will wrap onto multiple lines from bottom to top.
This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow the line.
Flexbox is a broad topic, but once you start with it, step by step, things become more understandable and easy.
I think that something that has caught my attention is that at the beginning I thought that this coding thing would be too boring and only for nerds or something similar... However, I think that to my surprise, I find myself enjoying it and wanting to know more and more. I like to communicate and without a doubt, coding is a form of communication and therefore a way of creating bridges. Do not stop exploring, there is much more to learn...
Source:Â https://css-tricks.com/