JSFiddle - React, Tailwind, and code Playground
HTML
<h2>Флоаты</h2>
<div>
<span class="left">Hello</span>
<img src="https://static.qiwi.com/img/qiwi_com/category/904_l.png" alt="">
<span class="right">World</span>
</div>
<h2>Флекс</h2>
<section>
<span>Hello</span>
<img src="https://static.qiwi.com/img/qiwi_com/category/904_l.png" alt="">
<span>World</span>
</section>
SCSS
// float
div {
margin: 50px auto;
width: 220px;
padding: 2px 30px;
position: relative;
text-align: center;
background: gray;
color: #fff;
font-size: 24px;
font-weight: bold;
&:after {
content: "";
display: table;
clear: both;
}
img {
position: absolute;
top: -55%;
left: 48%;
height: 70px;
width: 70px;
transform: translateX(-50%);
}
.left {
float: left;
}
.right {
float: right;
}
}
// flex
section {
display: flex;
align-items: center;
justify-content: space-between;
margin: 50px auto;
padding: 2px 30px;
height: 31px;
width: 220px;
color: #fff;
font-size: 24px;
font-weight: bold;
background: gray;
img {
height: 70px;
width: 70px;
}
}
//common
h2 {
margin: 30px;
text-align: center;
font-size: 35px;
text-decoration: underline;
}