Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make left elements unaffected when using display flex

.location-text {
  font-family: 'Inter';
  display: inline-block;
  word-break: break-word;
  font-style: normal;
  font-weight: 700;
  font-size: 16px;
  line-height: 26px;
  align-items: center;
  color: #13233A;
}

.list-contact {
  display: flex;
}

.icon-address {
  width: 22px;
  height: 22px;
  background: #EAA9A9;
  border-radius: 8px;
  align-items: center;
  display: flex;
  justify-content: center;
}
<div class="col-md-3 col-sm-6 col-xs-12 bootCols">
  <div class="title location">
    <i class="bx bx-location-plus localst"></i>
    <span class="location-text">Trụ sở (TP. Vinh)</span>
  </div>
  <div class="list-contact">
    <div class="icon-address">
      <img src="./image/home/address.png" alt="">
    </div>
    <div class="content-address">
      <span>Do Something Do Something Do Something Do Something Do Something Do        Something Do Something</span>
    </div>
  </div>
</div>

I have a frame like the following and I want to display flex so that they are on one row:

enter image description here

And I wanted the icon and content to be on the same line so I used display flex and it affected the width of the right icon. Here is my HTML and CSS code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

And this is the result I got:

enter image description here

So is there a way to make the element containing my icon unaffected? Hope to get a solution from you

>Solution :

you just need to put the elements correctly, so that the layout is as expected

.location-text{
font-family: 'Inter';
display: inline-block;
word-break: break-word;
font-style: normal;
font-weight: 700;
font-size: 16px;
line-height: 26px;
align-items: center;
color: #13233A;
}
.list-contact{
 display: flex;
}
.icon-address{
  width: 22px;
  height: 22px;
  background: #EAA9A9;
  border-radius: 8px;
  align-items: center;
  display: flex;
  justify-content: center;
}

.content-address{
  width: 200px
}
<div class="col-md-3 col-sm-6 col-xs-12 bootCols">
  <div class="title location">
    <i class="bx bx-location-plus localst"></i>
    <span class="location-text">Trụ sở (TP. Vinh)</span>
  </div>
  <div class="icon-address">
        <img src="./image/home/address.png" alt="">
    </div>
  <div class="list-contact">
    <div class="content-address">
     <span>Do Something Do Something Do Something Do Something Do Something Do        Something Do Something</span>
    </div>
  </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading