Previous Message
Next Message

float causing container not to wrap?

Sent by Tony Dupre on 25 March 2006 08:08

I realize there is most likely a simple fix for this but I have tried
everything I can think of - here is my problem:

I'm trying to position some div elements (sub1, sub2) inside of a container
div. The container div with automatically resize to fit the subs in it,
until I give sub1 "float:left". At that point, the container div no longer
auto sizes to fit sub1 into it.

Along with that, if sub1 is floated left, the left side of sub2 overlaps the
top of sub1.

So, I have two questions:

1. How can I float a div element and still have the container auto size
around it?

2. As for sub2 overlapping with sub1, I realize I can float sub2 left to get
rid of the overlapping, but then it no longer auto sizes to fill up the
remaining horizontal space in the container. So, how can I have it not
overlap, but still take up the remaining space?

The code I've put below does not yet have the "float:left" attributes put
into sub1 or sub2 divs yet. If you don't quite know what I mean, take a look
at my code, then put float:left into sub1, see what happens, then into
(also, I tried it without giving sub1 specific width or height, and that
doesn't seem to help)


<?xml version="1.0" encoding="UTF-8"?>

<html xmlns="" xml:lang="en">

<style type="text/css">

div {

..container {
  border:1px solid black;

..sub1 {
  border:1px solid lime;

..sub2 {
  border:1px solid purple;




<div class="container">

    <div class="sub1">

    <div class="sub2">



css-discuss [EMAIL-REMOVED]]
IE7b2 testing hub --
List wiki/FAQ --
Supported by --
Previous Message
Next Message