Fix a box 250px from top of content with wrapping content

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-06-09T18:45:45Z Indexed on 2010/06/10 4:23 UTC
Read the original article Hit count: 336

Filed under:
|
|
|

I'm having trouble left aligning a related links div inside a block of text, exactly 250 pixels from the top of a content area, while retaining word wrapping. I attempted to do this with absolute positioning, but the text in the content area doesn't wrap around the content.

I would just fix the related links div in the content, however, this will display on an article page, so I would like for it to be done without placing it in a specific location in the content.

Is this possible? If so, can someone help me out with the CSS for this?

Example image of desired look & feel...

UPDATE: For simplicity, I've added example code. You can view this here: http://www.focusontheclouds.com/files/example.html.

Example HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
  <title>Example Page</title> 
  <style>
    body {
      width: 400px; 
      font-family: Arial, sans-serif;
    }
    h1 {
      font-family: Georgia, serif; 
      font-weight: normal;
    }
    .relatedLinks {
      position: relative;
      width: 150px; 
      text-align: center; 
      background: #f00; 
      height: 300px; 
      float: left; 
      margin: 0 10px 10px 0;
    }
  </style> 
</head>
<body> 
  <div class="relatedLinks"><h1>Related Links</h1></div>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc tempus est luctus ante auctor et ullamcorper metus ullamcorper. Vestibulum molestie, lectus sed luctus egestas, dolor ipsum aliquet orci, ac bibendum quam elit blandit nulla.</p>
  <p>In sit amet sagittis urna. In fermentum enim et lectus consequat a congue elit porta. Pellentesque nisl quam, elementum vitae elementum et, facilisis quis velit. Nam odio neque, viverra in consectetur at, mollis eu mi. Etiam tempor odio vitae ligula ultrices mollis. </p>
  <p>Donec eget ligula id augue pulvinar lobortis. Mauris tincidunt suscipit felis, eget eleifend lectus molestie in. Donec et massa arcu. Aenean eleifend nulla at odio adipiscing quis interdum arcu dictum. Fusce tellus dolor, tempor ut blandit a, dapibus ac ante. Nulla eget ligula at turpis consequat accumsan egestas nec purus. Nullam sit amet turpis ac lacus tincidunt hendrerit. Nulla iaculis mauris sed enim ornare molestie. </p>
  <p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas non purus diam. Suspendisse iaculis tincidunt tempor. Suspendisse ut pretium lectus. Maecenas id est dui.</p>
  <p>Nunc pretium ipsum id libero rhoncus varius. Duis imperdiet elit ut turpis porta pharetra. Nulla vel dui vitae ipsum sollicitudin varius. Duis sagittis elit felis, quis interdum odio. </p>
  <p>Morbi imperdiet volutpat sodales. Aenean non euismod est. Cras ultricies felis non tortor congue ultrices. Proin quis enim arcu. Cras mattis sagittis erat, elementum bibendum ipsum imperdiet eu. Morbi fringilla ullamcorper elementum. Vestibulum semper dui non elit luctus quis accumsan ante scelerisque.</p>
</body>
</html>

© Stack Overflow or respective owner

Related posts about html

Related posts about css