Two Different Methods
We used two methods for creating columns on this mini site.
The front page and the four columns use a slighlty different method than was used on the interior pages.
The Card
CSS cards are a popular design element used to display content in a visually appealing and organized manner.
They are versatile and can be used for various purposes such as showcasing products, presenting information or previewing articles.
The four columns(cards) on the front page were quite a bear using conventional CSS. Not so with flexbox.
We have 4 equal cards nested in a card-container division.
Child Containers
If you want text to flow around your images, use conventional CSS properties like float and text-align inside child containers.
In this example <div class="card"></div> are your child containers.
The width of the cards on the front page were set using flex: 1; which tells the browser to create columns or cards of equal size and allow them to shrink and grow as needed.
Interior Pages
The interior pages use different code because the wrap procedure isn't as demanding.
The front page and its 4 cards needed to wrap to two columns, thus we used a media query to change their width to 50% and force them to wrap.
The CSS
div.card-container {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
margin: 0 10dvw;
gap: 2dvw;
position: relative;
z-index: -10;
}
/* Card container */
.card {
flex :1;
position:relative;
background: white;
border-radius: 1rem;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
overflow: hidden;
max-width: 300px;
transition: transform 0.2s ease;
}
The HTML
4 cards front
<div class="card-container">
<div class="card">
</div>
<div class="card">
</div>
<div class="card">
</div>
< div class="card">
</div>
</div>