Lädt...


🔧 Learn CSS layouts by example - Flexbox (part 2: gap/wrap)


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

This is the second tutorial in the series of "CSS layouts by example" tutorials. In the previous tutorial, we learned the basic concepts of Flexbox through two examples.

In this post, I'll demonstrate two simple, yet very important CSS properties we can use in Flexbox layout:

  1. gap (column-gap/row-gap)

  2. flex-wrap

I'll be using DoTenX UI builder, and you can create a free account and follow along with me.

This is the layout we want to acheive with flex-box and the CSS properties gap and flex-wrap

We are using the card element we created with flex layout in the last tutorial, however, you can even use simple Box elements with fixed width instead, to see the effect of these CSS properties.

This image from Freepik is used in this tutorial.

Step 1:

We start by adding a Box that renders a div element to our page.

Step 2:

Add 6 copies of the card element to the Box, and this is how it will look like:

Note: The default value of display property of Box is block, that's why the components are laid in a column.

Step 3:

Set the display property of the wrapper Box to flex so we make it our flex container.

As you can see our items are placed next to each other and are shrunk to fit in the Box which is the default behaviour.

Step 4:

Set the flex-wrap property to wrap. This property sets whether flex items are forced onto one line or can wrap onto multiple lines.

As you can see in the picture above, the elements are wrapped onto multiple lines. However, there is an issue. There is no space between the elements.

Step 5:

Set the column-gap property of the wrapper Box to 40px.

Using the column-gap property, we could create a space between columns, however, there is still another issue. There is no space between the rows.

Step 6:

Set the row-gap property of the wrapper Box to 40px.

And finally, with a flashback to the previous tutorial, we set justify-conent to center to centre the cards on the screen.

Try to resize your window now and see what happens. Is this what you expected?

Leave a comment if you have any questions and follow me for practical tutorials.

Remember to create your free account at https://dotenx.com to easily improve your web design skills and share the results with everyone.

...

🔧 Introduction of CSS, What is CSS, Why we use CSS and How CSS describe the HTML elements


📈 33.56 Punkte
🔧 Programmierung

🔧 Learn CSS layouts by example - Flexbox (part 2: gap/wrap)


📈 32.44 Punkte
🔧 Programmierung

🔧 BASIC OF RUST WITH EXECRISE - LEARN RUST WITH EXAMPLE (PART 1)


📈 27.87 Punkte
🔧 Programmierung

🔧 Is www.example.com and example.com is same in front of google


📈 25.93 Punkte
🔧 Programmierung

🔧 CSS Grid: Moving From CSS Frameworks To CSS Grid (2018 and beyond)


📈 25.17 Punkte
🔧 Programmierung

🔧 Choosing the Right CSS Approach: Tailwind CSS vs Bootstrap vs Vanilla CSS


📈 25.17 Punkte
🔧 Programmierung

🔧 A BRIEF REVIEW OF CSS CASCADING, CSS SELECTORS and CSS SPECIFICITY.


📈 25.17 Punkte
🔧 Programmierung

🔧 Stylify CSS: Automagic CSS bundles splitting into CSS layers in Astro.build


📈 25.17 Punkte
🔧 Programmierung

🔧 CSS Tip: learn CSS the easy way!


📈 25.13 Punkte
🔧 Programmierung

🔧 6 CSS Games to help you Learn CSS Easily


📈 25.13 Punkte
🔧 Programmierung

🔧 Learn CSS by Building the Google Logo in Pure CSS


📈 25.13 Punkte
🔧 Programmierung

🔧 Learn CSS by Building the Git Logo in Pure CSS


📈 25.13 Punkte
🔧 Programmierung

🔧 Learn CSS by Building the Nextflix Logo in Pure CSS


📈 25.13 Punkte
🔧 Programmierung

🔧 Learn CSS by Building the React Logo in Pure CSS


📈 25.13 Punkte
🔧 Programmierung

🔧 Learn CSS by Building the Microsoft Logo 2 Different Ways in Pure CSS


📈 25.13 Punkte
🔧 Programmierung

🔧 Learn CSS by Building the YouTube Logo in Pure CSS


📈 25.13 Punkte
🔧 Programmierung

🔧 Learn CSS by Building the Figma Logo in Pure CSS


📈 25.13 Punkte
🔧 Programmierung

🎥 10 modern layouts in 1 line of CSS


📈 25.05 Punkte
🎥 Video | Youtube

🔧 CSS Grid: Nested Grid Layouts


📈 25.05 Punkte
🔧 Programmierung

🔧 Hui Jing Chen - Demystify Modern CSS Layouts with DevTools - View Source 2019


📈 25.05 Punkte
🔧 Programmierung

🔧 CSS Grid: Creating Masonry Layouts


📈 25.05 Punkte
🔧 Programmierung

🔧 Understanding modern CSS layouts with Firefox DevTools - by HJ Chen | Mozilla Developer Roadshow EU


📈 25.05 Punkte
🔧 Programmierung

🔧 CSS Grid for UI Layouts


📈 25.05 Punkte
🔧 Programmierung

🔧 CSS Layout Techniques - Floats, Clears, and Legacy Layouts: The Old School Cool


📈 25.05 Punkte
🔧 Programmierung

🔧 CSS Box Model: The Secret Sauce of Web Layouts


📈 25.05 Punkte
🔧 Programmierung

🔧 Mastering Responsive Layouts: Achieving Complex Designs with CSS Grid


📈 25.05 Punkte
🔧 Programmierung

🔧 Exploring CSS Custom Layouts: Creating Unique and Non-Rectangular Designs


📈 25.05 Punkte
🔧 Programmierung

🔧 Why and How to Use Box-Sizing: 'Border-Box' in Your CSS Layouts


📈 25.05 Punkte
🔧 Programmierung

🔧 CSS for Beginners: Building Responsive Web Layouts with Ease


📈 25.05 Punkte
🔧 Programmierung

🔧 Crafting Perfect Layouts: Mastering CSS Layout Techniques.🚀


📈 25.05 Punkte
🔧 Programmierung

🔧 Modern CSS Layouts: You Might Not Need A Framework For That


📈 25.05 Punkte
🔧 Programmierung

🔧 Main layouts - Beer CSS Tips #4


📈 25.05 Punkte
🔧 Programmierung

matomo