views:

45

answers:

2

In the screen shot you see a list of items on the left (not floated) and a display box on the right (floated). How can I prevent the left item's li element from cutting into the display box. The li content follows the flow and breaks to a new line before running into the display box, but the li element, as in the container, does not.

Left div cuts into right div

Li items on the left:

border: 1px solid #000000;
display: block;
margin-bottom: 8px;
padding: 10px;

Display box on the right:

border: 3px double #000000;
display: inline-block;
float: right;
margin-left: 20px;
padding: 15px;
width: auto;

Thanks, Ryan

AFTER ROBERT'S SUGGESTION:

Adding inline-block to li element

RESPONSE TO TIM B

The widths are dynamic on different pages, dynamic as in different per page, but they won't change on a per page basis, except for the li elements that go beyond the display box. Just like when you float a pictures to the left and the text sits on the right of the pictures, but once the pictures ends, the text continues underneath the image all the way to the right edge of the page, that's what I want in reverse. So I want the li element to go to the left edge of the right display box, but past the box, I want to go to the edge of the page. The text itself conforms to this, but for some reason, the li element does not recognize there to be an "object" to prevent it from stopping and cutting into the display box. The reason it doesn't recognize it is because of the right floated display box, which breaks things from the normal flow, but I would think there has to be a way to either manipulate the display box to it can be recognized or manipulate the li elements so they can recognize the display box.

A: 

If you float an element and not others then you will run into these issues. Try floating the ul element and also giving the items widths.

Tim B James
I can certainly float the ul element, however the reason I don't want to give the ul/li elements a width, is because (1) although they will be the same width on each page, I have several pages that would require the ul/li width to be different. I have considered overwriting the style on a per page basis, but that leaves me with problem (2) which is the fact that some display boxes have a large width and ideally I want to content to go to the right edge of the page (so more content fill fit in one line), otherwise I would have a long unbalanced page -- does that make sense?
Ryan S.
Would setting the widths using jQuery be an option? Say you were to grab the width of the display box, then calculate the widths of the ul>li elements? Not an ideal solution as someone with scripts turned off would not see the correct layout.
Tim B James
What about problem (2) that if I set the width, it won't wrap around the display box once the li element is below it? I suppose I could also get the height and make some calculations there, but that seems like a lot of logic to achieve something that the text content is naturally doing, just the container somehow is not flowing accordingly. I prefer a pure CSS solution, but it may not be possible?!
Ryan S.
if you float the display box right, then it will stay where it is and the ul>li floating left with have their widths set so will not run into the display box. A pure CSS solution may not be possible as it sounds as though the widths are almost dynamic on different pages.
Tim B James
See my response up top, because there wasn't enough space here :)
Ryan S.
A: 

If you knew what the max width of the right hand column would be, you could add margin-right:00px; to either the list items or list itself.

accidentalgenius
The right column (display box) changes in width based on the type of content.
Ryan S.