I always run into this problem when I use flexbox to center my content, where my button ends up spanning the full width of the div. I want it to only take up the space it needs.
Code:
HTML:
<div class="who__text-content">
<h2 class="u-margin-bottom-2">Who</h2>
<h2 class="u-margin-left-2 u-margin-bottom-2">Lorem ipsum</h2>
<p class="u-margin-left-2 u-margin-bottom-6">Lorem ipsum</p>
<a href="#" class="btn u-margin-left-2">Meet The Team</a>
</div>
Sass:
.btn {
padding: 1.3rem 3.7rem;
width: auto;
}
.who {
&__text-content {
padding-bottom: 1.3rem;
display: inline-flex;
flex-direction: column;
justify-content: center;
align-content: center;
margin: auto;
height: 100%;
<!-- I tried using the code bellow instead of the code above with position: relative; on the parent element. It ensures the button doesn't span the fullwidth but then all of the content becomes squished and doesn't use all the available space. -->
// position: absolute;
// top: 50%;
// left: 50%;
// transform: translate(-50%, -50%);
}
}
Thanks in advance