2

In this code the first div shows 3rem width. The svg circle should also be 3rem wide, which it is if I remove display:flex. But when it is flex, the svg shrinks. How can I enforce this size? I want to have fluid layout and use rem not px.

If I remove the long sentence and keep only 'Lorem ipsum' then svg also is 3rem. Something about the combination of long text next to svg and flexbox that is pushing the svg to become too small.

<div style='background: black; width:3rem'>
  3 rem
</div>
<span style='display:flex'>
  <svg viewBox="0 0 100 100" style='width:3rem' xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="50" /></svg>
  <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem unde, aliquid harum suscipit numquam. Reiciendis, earum! Eveniet, voluptate, at asperiores animi quis nesciunt facilis, labore officiis necessitatibus iusto repellat iure.</div>
</span>
user779159
  • 9,034
  • 14
  • 59
  • 89

2 Answers2

0

You can try something like this. Just wrap SVG with one div.

<div style='background: black; width:3rem'>
   3 rem
</div>
<span style='display:flex'>
   <div>
     <svg viewBox="0 0 100 100" style='width:3rem' xmlns="http://www.w3.org/2000/svg"> 
        <circle cx="50" cy="50" r="50" />
     </svg>
   </div>
  <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem unde, liquid 
    harum suscipit numquam. Reiciendis, earum! Eveniet, voluptate, at asperiores animi 
     quis nesciunt facilis, labore officiis necessitatibus iusto repellat iure.
  </div>
</span>
Veselin Kontić
  • 1,638
  • 2
  • 11
  • 23
0

Check this:

<div style='background: black; width:3rem'>
  3 rem
</div>
<span style='display:flex'>
  <div style='min-width:3rem'>
     <svg viewBox="0 0 100 100" style='width:auto' xmlns="http://www.w3.org/2000/svg">
    <circle cx="50" cy="50" r="50" />
  </svg>
  </div>
  <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem unde, aliquid harum suscipit numquam. Reiciendis, earum! Eveniet, voluptate, at asperiores animi quis nesciunt facilis, labore officiis necessitatibus iusto repellat iure.</div>
</span>
Sunil
  • 411
  • 5
  • 12