Вам действительно нужно обернуть элемент right-text
, icon
и left-text
в childContainer
, а затем обернуть элемент childContainer
в parentContainer
wrap.
<div class="parentContainer">
<div class="childContainer">
<div class="right-text">Right</div><div class="icon"></div><div class="left-text">Left</div>
</div>
</div>
Далее,Вы должны применить FlexBox
со значением center justify-content
и align-items
, а также добавить height: 100vh
.Указанные изменения применяются к приведенному ниже фрагменту кода.Попробуйте это, я надеюсь, это поможет вам.Спасибо
body {
padding: 0;
margin: 0;
}
.right-text {
position: relative;
display: inline-block;
font-family: arial;
font-size: 13px;
}
.icon {
position: relative;
display: inline-block;
width: 32px;
height: 32px;
background: url("https://i.imgur.com/VXlnn8a.png");
}
.left-text {
position: relative;
display: inline-block;
font-family: arial;
font-size: 13px;
font-weight: 700;
}
.parentContainer {
display: flex;
height: 100vh;
justify-content: center;
align-items: center;
}
<div class="parentContainer">
<div class="childContainer">
<div class="right-text">Right</div><div class="icon"></div><div class="left-text">Left</div>
</div>
</div>