title: Wrapping text around an absolute positioned element
body: <p>I'm stuck on something where I have a loads of content pages with a message box. In this message box, you could have images, text, headers etc. However each message box will have an Icon in the top right of the box. The image will sit in the top of the box fine if i use position:absolute. However If the message box has a header or a paragraph and fills with the width of the box. The text will sit underneath the image.</p>
  
  <p>I basically need a wrapper around the image which has a width so the text will only go sit up until the edge of the image. I'm 99% sure i got it working in firebug by wrapping the absolute positioned image in a div and giving it some styles. But I can't seem to get it working today!</p>
  
  <p>There are hundreds of pages, so moving the HTML around is not an option. The image doesn't currently have a wrapper. So i'm having to use Jquery to wrap the image. (That's if it's the answer).</p>
  
  <p>I know that position absolute takes the element outside of the document flow, but is there something I can do?</p>
  
  <p>Anyway here is my code so far:</p>
  
  <pre><code>&lt;div class="message"&gt;
  &lt;h3&gt;Some text, a header perhaps? But this is the next that will sit under the image, sometimes it's a p tag.&lt;/h3&gt;
  &lt;img class="messageIcon" src="/link-to-icon/which-are-the-same-size" border="0" width="64" &gt;
  &lt;p&gt;Some more random text that would appear in the messagebox this could go on for a few lines.&lt;/p&gt;
  &lt;/div&gt;
  
  
  &lt;script type="text/javascript"&gt;
  
  $(document).ready(function(){
      $('img.messageIcon').wrap('&lt;div class="messageIconWrap" /&gt;');
  
      alert("this is a test");
  
  });
  
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>The JS wraps a div around the image</p>
  
  <p>CSS:</p>
  
  <pre><code>.messageIconWrap{
      display: inline-block;
      float:right;
      height:60px;
      width:60px;
  }
  
  div.message {
      position: relative;
  }
  .message {
      background: none repeat scroll 0 0 #393939;
      clear: both;
  }
  
  .messageIcon {
      position: absolute;
      right: 20px;
      top: 20px;
      float: right;
  }
  </code></pre>
  
  <p>JS Fiddle - <a href="http://jsfiddle.net/jdp7E/" rel="nofollow noreferrer">http://jsfiddle.net/jdp7E/</a></p>