I have a html code and i want to align theme like the image below: aligned image
My html code:
<button class="container">
<span class="btn__img"></span>
<span class="btn__txt">Basic</span>
</button>
I have a html code and i want to align theme like the image below: aligned image
My html code:
<button class="container">
<span class="btn__img"></span>
<span class="btn__txt">Basic</span>
</button>
.container{
display: flex;
flex-direction: column;
justify-content: center; // if you want to align it center vertically
align-items: center; // if you want to align it center horizontally
}
Apply this css to your button.
Method 1.
You can use a flex layout with column direction.
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.container span {
border: 1px solid #000;
}
<button class="container">
Button
<span class="btn__img">First Span</span>
<span class="btn__txt">Second Span</span>
</button>
Method 2.
You can use the display:block for the spans to achieve this.
.container span {
display:block;
border: 1px solid #000;
}
<button class="container">
Button
<span class="btn__img">First span</span>
<span class="btn__txt">Second span</span>
</button>