Place the image in the middle of a block of text

Without separating the line and only CSS , 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/

+7
html css html5 css3
source share
1 answer

Yes,

you can use the floatting element to flush your floating image.

see demo below using 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/

+11
source share

All Articles