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 can I prevent the text from splitting into two blocks and maintain the correct order when adding tags like <strong>?

The Original Code.

<div style="display: flex; flex-direction: column;">
  <a href="xxxxxx" target="_blank" style="text-decoration: none; display: flex; align-self: stretch; align-items: flex-start; flex-shrink: 0; padding: 8px 0px; cursor: pointer;">
    <img
      src="public/common/like&comment.png"
      alt="like&comment"
      style="width: 68px; height: 68px; align-self: stretch;"
    />
    <div style="display: flex; flex-grow: 1; align-self: stretch; align-items: center; color: #212121; margin-left: 16px;">
      This is a testing title to be perform- Important topic to be announce
    </div>
  </a>

  <a>
    .....
  </a>
</div>

And this is how it looks like.
enter image description here

When I tying to add or other tag, the text will be mess up, turn into two block. How can I make it have a correct order?

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

<div style="display: flex; flex-direction: column;">
  <a href="xxxxxx" target="_blank" style="text-decoration: none; display: flex; align-self: stretch; align-items: flex-start; flex-shrink: 0; padding: 8px 0px; cursor: pointer;">
    <img
      src="public/common/like&comment.png"
      alt="like&comment"
      style="width: 68px; height: 68px; align-self: stretch;"
    />
    <div style="display: flex; flex-grow: 1; align-self: stretch; align-items: center; color: #212121; margin-left: 16px;">
      This is a testing title to be perform- <strong>Important topic to be announce</strong>
    </div>
  </a>

  <a>
    .....
  </a>
</div>

enter image description here

>Solution :

The reason is you have used display:flex; on the parent in which you are adding <strong>...</strong> element. And you <strong> element is treated as a flex-item now and it splits as per flex properties mentioned. Now there is one parent with two flex-items, you normal text and your <strong> element, that is why it is behaving like this.

All you need to do is remove display:flex; from the div. Something like this would do it for you.

  <div style="color: #212121; margin-left: 16px;">
      This is a testing title to be perform- <strong>Important topic to be announce</strong>
    </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