search

Home  >  Q&A  >  body text

Display an element after a block newline

I currently have this:

I want to put the icon div at the end of the text, but since it's a "block" I can't make it work.

Desired output:

code segment:

* {
  font-family: Arial, 'sans-serif'
}

.test {
  display: flex;
}

.info {
  font-family: 'monospace';
  background: black;
  width: 18px;
  height: 18px;
  aspect-ratio: 1;
  text-align: center;
  border-radius: 50%;
  color: white;
}
<div class="test">
    Donec rutrum congue leo eget malesuada.     Donec sollicitudin molestie malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
   <div class="info">i</div>
</div>

P粉652495194P粉652495194257 days ago397

reply all(1)I'll reply

  • P粉738676186

    P粉7386761862024-04-05 20:34:40

    1. Remove from container display: flex (.test)
    2. Set the info icon (.info) to inline-block and use display: inline-block

    * {
      font-family: Arial, 'sans-serif'
    }
    
    .info {
      display: inline-block;
      font-family: 'monospace';
      background: black;
      width: 18px;
      height: 18px;
      aspect-ratio: 1;
      text-align: center;
      border-radius: 50%;
      color: white;
    }
    Donec rutrum congue leo eget malesuada. Donec sollicitudin molestie malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    i

    reply
    0
  • Cancelreply