Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent absolutely-positioned elements from overlapping with text

I have a unique situation here.

Essentially, I have an absolutely positioned block of text, which must be absolutely positioned due to design limitations.

I also have the rest of my text, which is normally positioned. However, I need to prevent my normal text from overlapping with my original text.

Is this possible simply with HTML and inline CSS? I do not have access to JavaScript or external/head-related CSS; only inline styles are available. I have created a simplified version of my CSS with this jsFiddle.

like image 247
kevinji Avatar asked Jun 10 '11 03:06

kevinji


People also ask

How do you make an absolute element not overlap?

By setting absolute position you're removing the element from the document flow, but the behaviour you want is that your element should be be pushed around by its siblings so as not to overlap... ie it should flow!

What happens when an element is positioned absolutely?

Absolutely positioned elements are removed entirely from the document flow. That means they have no effect at all on their parent element or on the elements that occur after them in the source code.

How do I stop images from overlapping in CSS?

Remove the width from your #inner div and set a margin on the right of it that is the full width ( margin + padding + width + etc. ) of your figure . The figure will float into the right margin of #inner . Since DIVs are block level elements they take up 100% width by default.


1 Answers

Is a solution to create another div (div2) that overlaps the absolutely positioned div (div1), but is itself invisible? Then the rest of the text would avoid overlapping div2...

Sketched this out here: http://jsfiddle.net/VKYwD/8/

Not entirely clear on what your constraints are though.

like image 111
Steve Bennett Avatar answered Oct 06 '22 20:10

Steve Bennett