1

I have read countless posts on this topic however I am yet to find a solution that works. I simply want to have two divs side by side with the LHS div being the width of the FA char and the RHS div being the remainder.

<div class="helper">
  <div class="text-info"><i class="fa fa-info-circle fa-2x"></i></div>
  <div class="text-muted">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin non tincidunt ante. Duis a est ipsum. Morbi vulputate neque vitae nibh sodales gravida. Etiam viverra vulputate est nec faucibus. Nullam volutpat sagittis augue, et mattis nisi facilisis vel. Nunc eu dignissim lectus, vitae venenatis nisi. Proin euismod, enim nec pulvinar maximus, mi justo luctus odio, in tristique dolor augue nec lacus.
  </div>
</div>
Dercni
  • 1,216
  • 3
  • 18
  • 38

3 Answers3

1

Set display:table-cell to your content and icon will give the desired output. Check below snippet.

.inline {
  display: table-cell !important;
  width: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="helper">
  <div class="text-info"><i class="fa fa-info-circle fa-2x inline"></i></span>
    <div class="text-muted inline">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin non tincidunt ante. Duis a est ipsum. Morbi vulputate neque vitae nibh sodales gravida. Etiam viverra vulputate est nec faucibus. Nullam volutpat sagittis augue, et mattis nisi facilisis vel.
      Nunc eu dignissim lectus, vitae venenatis nisi. Proin euismod, enim nec pulvinar maximus, mi justo luctus odio, in tristique dolor augue nec lacus.
    </div>
  </div>
RaJesh RiJo
  • 4,302
  • 4
  • 25
  • 46
1

Not sure what you're trying to do but you could use something like Flexbox which is in the JS fiddle here.

Alternatively you could do something like this:

HTML

<div class="helper">
  <div class="text-info">FA</div>
   <div class="text-muted">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin non tincidunt ante. Duis a est ipsum. Morbi vulputate neque vitae nibh sodales gravida. Etiam viverra vulputate est nec faucibus. Nullam volutpat sagittis augue, et mattis nisi facilisis vel. Nunc eu dignissim lectus, vitae venenatis nisi. Proin euismod, enim nec pulvinar maximus, mi justo luctus odio, in tristique dolor augue nec lacus.
  </div>
</div>

CSS

.text-info, .text-muted {
  float:left;
}
.helper {
  clear:both;
}

If you want both of them to have different widths, you can simply set the widths of each (using %, px or whatever).

zik
  • 3,035
  • 10
  • 41
  • 62
1

I believe this is what you're going for :

.text-muted {
  display: table-cell;
}

.text-info {
  padding-right: 10px;
  display: block;
  float: left;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="helper">
  <div class="text-info"><i class="fa fa-info-circle fa-2x"></i></div>
  <div class="text-muted">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin non tincidunt ante. Duis a est ipsum. Morbi vulputate neque vitae nibh sodales gravida. Etiam viverra vulputate est nec faucibus. Nullam volutpat sagittis augue, et mattis nisi facilisis vel. Nunc eu dignissim lectus, vitae venenatis nisi. Proin euismod, enim nec pulvinar maximus, mi justo luctus odio, in tristique dolor augue nec lacus.
  </div>
</div>

See also this Fiddle.

John Slegers
  • 45,213
  • 22
  • 199
  • 169
  • yes this should work. +1 – RaJesh RiJo Sep 11 '17 at 10:14
  • This is the closest any of the suggested solutions have come. Is it possible to have the text closer to the top as it is currently stepped down due to the size of the FA icon? – Dercni Sep 11 '17 at 10:26
  • @Dercni : You might want to try `float : left` for `.text-info` and `display: table-cell;` for `.text-muted`. See [**this demo**](https://jsfiddle.net/4Lgxnj4m/3/)! – John Slegers Sep 11 '17 at 10:52
  • @Dercni : I updated my answer in correspondence with your other requirements! – John Slegers Sep 11 '17 at 10:53