tags:

views:

504

answers:

3

Hi there,

I ma having an issue with divs and css and especially floats.. I need to convert a page that is heavy using tables and columns and rows, my idea is to create a div for each column but of course i need to float these.

What are the rules for floating? I should float left each Div until i come to the end and then i must "clear" the float?

Is it good practice to use Width / Height on a div others i can't float them correctly?? or is it better to use min-height ?

Of course my idea is removing all the css stuff to a css external style sheet so i presume i need to give each div and ID so that i can assign a float / style to it... or of course if they are all the same i can assign a css class?

Any help really appreciated

Thank you

+1  A: 
<div id="mytable">
    <div class="left"></div>
    <div class="right"></div>
    <div class="clearer"></div>
</div>

<style>
   .left,.right {
      float:left;
      width:100px;
   }
   .clearer {
     clear:both;
     height:0;
   }
</style>

This is the way i style my "tables", it works in all browsers.

Henrik Adolfsson
A: 

I am having an issue with divs and css and especially floats.. I need to convert a page that is heavy using tables and columns and rows, my idea is to create a div for each column but of course i need to float these.

Sounds fine. Beware, though, that converting table layout to CSS layout might be tricky if you want to keep the appearance 100% the same.

What are the rules for floating? I should float left each Div until i come to the end and then i must "clear" the float?

Let me answer by example:

<div style="float: left;">Column 1</div>
<div style="float: left;">Column 2</div>
<div>Column 3</div>
<div style="clear: left;">Stuff below the three columns</div>

Is it good practice to use Width / Height on a div others i can't float them correctly?? or is it better to use min-height ?

That depends on whether you want the width/height to depend dynamically on the content or if you want it fixed. min-height can be useful in a lot of cases, but I think the question is too general to be answered.

Of course my idea is removing all the css stuff to a css external style sheet so i presume i need to give each div and ID so that i can assign a float / style to it... or of course if they are all the same i can assign a css class?

Yes.

Heinzi
Thank you... I also noticed - maybe i am missing something.. by my corners are inserted via a background-image on CSS and i need to tell is the size??? Is there a standard for a corner?? is it 12px. i am inserting a Uppercenter (between 2 corners) which has a background of red so i assume that the corners need to have images of the smae size? thanks again
mark smith
I don't really understand your question. I don't think there is a "standard" for corner sizes -- it depends on how large and fancy your corner is.
Heinzi