While there are numerous discussions on aspect ratio, I haven't come across a solution that fits my specific issue.
My dilemma is this:
I am looking to create a div with a perfect square aspect ratio within a flex parent set at 100% height.
Below is the current structure of my HTML:
<article class="article">
<header class="article-header">
<div class="article-header__user">
<div class="article-header__user-color"></div>
<p class="article-header__user-name">Damiano Mondaini</p>
</div>
<div class="article-header__more">
<a href="#" class="article-header__more-share-link">
<i class="article-header__more-share-icon">S</i>
</a>
</div>
</header>
</article>
This is the current CSS being used:
.article {
border-radius: 15px;
border: 1px solid #134B5F;
}
.article-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px;
}
.article-header__user {
display: flex;
justify-content: flex-start;
align-items: center;
}
.article-header__user-color {
background: red;
}
Please take note of the following:
serves as the flex parent<div class="article-header__user">
should be styled as a square<div class="article-header__user-color">
- Avoiding the use of JavaScript is preferred
Appreciate your assistance in advance!