Hi, I tried to make a dynamic page which will resize itself depending on the length of the content uploaded on that particular page. I used an initial wide div and then in it, made another two divs using float. However while i am getting it right in internet explorer, it is not so in firefox. Below is the code that i had used. Tell me whether i am doing anything wrong. <html> <head> <title>asd</title> <style> #a{width:700px; border:1px solid red;} #b{width:500px; border:1px solid green; float:left;} #c{width:195px;border:1px solid black;float:right;} </style></head> <body> <div id="a"> <div id="b">asdsd</div> <div id="c">asd</div> </div> asd
Firefox takes any height and width definition as an absolute, so it won't dynamically resize. To do that you'd need to use min-width. Then, of course, IE doesn't interpret min-width, so you still need to set the width for IE. You can do it like this: #a { min-width: 700px; } *html #a { width: 700px; } I'm not a hardcore CSS guy, so maybe I'll get flamed for being a hack, but it does work in all browsers AFAIK.
Its not the width that i am having problems with, its the height. If i use another div below the big one, in this case b below a , the whole content comes out of the wider div.
Add <div style="clear:both"></div> Code (markup): right after the closing </div> of #c So now your HTML code would look something like this: <div id="a"> <div id="b">asdsd</div> <div id="c">asd</div> <div style="clear:both"></div> </div> Code (markup): That should fix it Regards, -- Naif
While adding a clearing block element will do the job, it is not a best practice. The W3 strongly suggests that browsers ignore empty block elements. You are not guaranteed that the element will be rendered, thus no clearing action. There are several methods of clearing or enclosing float elements. See this enclosing float elements demo for the valid means and for IE hacks. cheers, gary