Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Place an image in the middle of a block of text

Tags:

html

css

Without splitting the string and with CSS only, is it possible to achieve the effect below?

enter image description here

<img class="image-in-text" src="www.imgurl.com/img.png">
<span class="text-around-image">
    Text goes here
</span>

http://jsfiddle.net/s6hp92c4/

like image 580
MattDiamant Avatar asked Nov 17 '15 19:11

MattDiamant


1 Answers

yes,

you can use a floatting element to push down your floatting image.

see demo below using a pseudo element :

body {
  font-family: sans-serif;
  font-weight: 300;
  line-height: 1.5em;/* set the unit to make sure it is applied in any browser */
}
div:before {
  content: '';
  padding-top: 3em;/* 2x 1.5em line-height */
  float: left;
}
img {
  float: left;
  clear: left;
  padding: 5px 10px 1px 0;
}
<div>
  <img src="http://fillmurray.com/88/88"/>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
    Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus
    lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor,
    facilisis luctus, metus</p>
</div>

http://jsfiddle.net/s6hp92c4/4/

like image 169
G-Cyrillus Avatar answered Oct 02 '22 07:10

G-Cyrillus