Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-06-2010, 10:42 AM   PM User | #1
effpeetee
Senior Coder

 
effpeetee's Avatar
 
Join Date: Feb 2007
Location: Clapham Junction - London SW
Posts: 4,884
Thanks: 228
Thanked 204 Times in 203 Posts
effpeetee is an unknown quantity at this point
Exclamation Cannot get table cells to be the same height. - html5/css3

This is an experiment to try to understand css display:table-cell etc.
The original code I have downloaded from the web and modified it to my required dimensions.
The table cells will not be the same height/length and I cannot find why.

I appreciate that it is still not finished, but the original site had equal cell lengths so I must have done something wrong.

I never was any good at tables when only html tables very available.
Any help would be much appreciated. I have been working on this forn several days and I am beginning to get war weary.

Rescue urgently required.

Frank
__________________
* Sources (updated: 21.11.2012.
Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.
effpeetee is offline   Reply With Quote
Old 09-06-2010, 12:08 PM   PM User | #2
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,817
Thanks: 9
Thanked 681 Times in 675 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
Hello Frank

It's the float settings on your table-cell divs that are causing the problem. Remove the floats and those three divs have the same height. You might need to change the order of your html to get the divs ordered correctly.
SB65 is offline   Reply With Quote
Old 09-06-2010, 12:12 PM   PM User | #3
Doctor_Varney
Regular Coder

 
Doctor_Varney's Avatar
 
Join Date: Mar 2008
Location: Midlands, UK
Posts: 649
Thanks: 45
Thanked 29 Times in 28 Posts
Doctor_Varney will become famous soon enough
Hey Frank. Ain't Firebug great for checkin' out someone's code!?

First thing that occurs to me is, if you're displaying divs as 'table' then why float?

To me (and 'tis just my own humble reasoning) the whole point of a table is to build a matrix - a grid - whose columns and rows must have equal height, by it's very definition!

Wheras, tables are linear and logical, floating is what I call an 'abstract behaviour' because it requires to transcend the 2 dimensions in order to do what would normally have been expressed as a linear structure.

Also, I presume 'display:table' creates a flow condition which precipitates the building of a matrix - therefore, floating (out of flow) must become unecessary... indeed, the antithesis of 'table'.

I have no idea what I'm talking about because I have never used this new property but those are the immediate thoughts which pop into my head.

No, I was never any good at tables either. That was more to do with it's attributes being inseparable from the markup. Everything is made easier with CSS - not just tables... except layout, which is always a challenge - even with the old methods.

Dr. V
__________________
Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.

Last edited by Doctor_Varney; 09-06-2010 at 12:16 PM..
Doctor_Varney is offline   Reply With Quote
Old 09-06-2010, 01:07 PM   PM User | #4
Lerura
Regular Coder

 
Lerura's Avatar
 
Join Date: Aug 2005
Location: Denmark
Posts: 869
Thanks: 0
Thanked 112 Times in 111 Posts
Lerura will become famous soon enough
In order to it make work properly you have to nest the divs as if they were ordinary table tags:
Code:
<table>
  <tr>
    <td></td>
    <td></td>
  </tr>
</table>
becomes
Code:
<div style="display:table">
  <div style="display:table-row">
    <div style="display:table-cell"></div>
    <div style="display:table-cell"></div>
  </div>
</div>
doing so, the divs automatically floats and "height"s just as if they were the related table element.

It is actually an alternative set of table elements.
so omitting e.g.<div style="display:table-row"> is just like omitting <tr> in the standard set. - It won't work

And they can't be combined:
e.g.
a <td> cannot go inside a <div style="display:table-row"> and vice versa.

The only noticable difference is that "table-cell"s by default is styled like a div (e.g. content is vertical top and no padding).
And AFAIK there is no equivalents to "rowspan" and "colspan"

Last edited by Lerura; 09-06-2010 at 01:13 PM..
Lerura is offline   Reply With Quote
The Following 2 Users Say Thank You to Lerura For This Useful Post:
Doctor_Varney (09-06-2010), effpeetee (09-06-2010)
Old 09-06-2010, 01:35 PM   PM User | #5
effpeetee
Senior Coder

 
effpeetee's Avatar
 
Join Date: Feb 2007
Location: Clapham Junction - London SW
Posts: 4,884
Thanks: 228
Thanked 204 Times in 203 Posts
effpeetee is an unknown quantity at this point
Thanks for your help although I was taught not to use tables this wise, so I know almost nothing about them.

The code that I used was largely downloaded from a url that did work. All that I did was to alter the widths to suite my purpose. Since then, it does not work properly.

Frank
__________________
* Sources (updated: 21.11.2012.
Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.
effpeetee is offline   Reply With Quote
Old 09-06-2010, 02:15 PM   PM User | #6
Lerura
Regular Coder

 
Lerura's Avatar
 
Join Date: Aug 2005
Location: Denmark
Posts: 869
Thanks: 0
Thanked 112 Times in 111 Posts
Lerura will become famous soon enough
As i see it, using "table" display is only suitable when you wanna float a group of divs and have them to have the same height.
Lerura is offline   Reply With Quote
Old 09-06-2010, 02:30 PM   PM User | #7
effpeetee
Senior Coder

 
effpeetee's Avatar
 
Join Date: Feb 2007
Location: Clapham Junction - London SW
Posts: 4,884
Thanks: 228
Thanked 204 Times in 203 Posts
effpeetee is an unknown quantity at this point
Precisely. That is why I want to use them with html5 and css3. I just cannot find an article that makes it clear to me. W3 states that if any stage is omitted, the css will automatically insert it.

Ah well press on. Thank you all for your help. I am determined to get their if it is the last thing I do. (the way I feel at the moment, It may very well be so!)

Frank

Perseverance pays.
__________________
* Sources (updated: 21.11.2012.
Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.
effpeetee is offline   Reply With Quote
Old 09-06-2010, 03:00 PM   PM User | #8
Lerura
Regular Coder

 
Lerura's Avatar
 
Join Date: Aug 2005
Location: Denmark
Posts: 869
Thanks: 0
Thanked 112 Times in 111 Posts
Lerura will become famous soon enough
Quote:
Originally Posted by effpeetee View Post
W3 states that if any stage is omitted, the css will automatically insert it.
testing it, I found that it is so, at least in my version above.
Lerura is offline   Reply With Quote
Old 09-06-2010, 03:25 PM   PM User | #9
effpeetee
Senior Coder

 
effpeetee's Avatar
 
Join Date: Feb 2007
Location: Clapham Junction - London SW
Posts: 4,884
Thanks: 228
Thanked 204 Times in 203 Posts
effpeetee is an unknown quantity at this point
Quote:
Originally Posted by lerura View Post
testing it, I found that it is so, at least in my version above.
What version above? I'd like to see it.

This is the original version.


Frank
__________________
* Sources (updated: 21.11.2012.
Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

Last edited by effpeetee; 09-06-2010 at 03:41 PM..
effpeetee is offline   Reply With Quote
Old 09-06-2010, 05:16 PM   PM User | #10
Doctor_Varney
Regular Coder

 
Doctor_Varney's Avatar
 
Join Date: Mar 2008
Location: Midlands, UK
Posts: 649
Thanks: 45
Thanked 29 Times in 28 Posts
Doctor_Varney will become famous soon enough
Quote:
Originally Posted by effpeetee View Post
I am determined to get their if it is the last thing I do. (the way I feel at the moment, It may very well be so!)

Frank

Perseverance pays.
Yes, Frank. I know exactly how you feel (and you know how I get sometimes!) Stick at it, mate! You're a gentleman, a scholar and an innovator.

Dr. V
__________________
Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.
Doctor_Varney is offline   Reply With Quote
Old 09-06-2010, 05:22 PM   PM User | #11
Doctor_Varney
Regular Coder

 
Doctor_Varney's Avatar
 
Join Date: Mar 2008
Location: Midlands, UK
Posts: 649
Thanks: 45
Thanked 29 Times in 28 Posts
Doctor_Varney will become famous soon enough
So, were we right? The floating was not needed, yes?

Lerura's post seemed to be the brightest light at the end of the dark tunnel. So, what you're saying is, that each div takes on the function of a seperate element of the old HTML table...? If so, it makes perfect sense, though doesn't seem so different to the way I've been using divs just lately in one of my own experiments. It opens a box of questions for me. But that's cool. Cheers!

Dr. V
__________________
Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.

Last edited by Doctor_Varney; 09-06-2010 at 05:27 PM..
Doctor_Varney is offline   Reply With Quote
Old 09-06-2010, 05:26 PM   PM User | #12
effpeetee
Senior Coder

 
effpeetee's Avatar
 
Join Date: Feb 2007
Location: Clapham Junction - London SW
Posts: 4,884
Thanks: 228
Thanked 204 Times in 203 Posts
effpeetee is an unknown quantity at this point
Quote:
Originally Posted by Doctor_Varney View Post
Yes, Frank. I know exactly how you feel (and you know how I get sometimes!)
Keeps me out of mischief.

Frank
__________________
* Sources (updated: 21.11.2012.
Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.
effpeetee is offline   Reply With Quote
Old 09-06-2010, 05:26 PM   PM User | #13
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,817
Thanks: 9
Thanked 681 Times in 675 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
Quote:
Originally Posted by effpeetee View Post
What version above? I'd like to see it.

This is the original version.
In that version none of the "table-cell" divs are floated, and additionally there is a wrapper div which has display:table. As per earlier post if you remove the float from #navcol, #sidecol and #main then then your original code isn't far off - certainly the columns are of equal length.
SB65 is offline   Reply With Quote
Old 09-06-2010, 08:09 PM   PM User | #14
effpeetee
Senior Coder

 
effpeetee's Avatar
 
Join Date: Feb 2007
Location: Clapham Junction - London SW
Posts: 4,884
Thanks: 228
Thanked 204 Times in 203 Posts
effpeetee is an unknown quantity at this point
Quote:
Originally Posted by SB65 View Post
In that version none of the "table-cell" divs are floated, and additionally there is a wrapper div which has display:table. As per earlier post if you remove the float from #navcol, #sidecol and #main then then your original code isn't far off - certainly the columns are of equal length.
I think we are getting there. This incorporates your suggestions. Thanks to you all for putting up with me. I have a bit of a bee in my bonnet over this project. I want to get it right before my next birthday.
I was born 14th September, 1925

It's here to view. I still need to add the rounded corners but I know how to do that.

Frank
__________________
* Sources (updated: 21.11.2012.
Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

Last edited by effpeetee; 09-06-2010 at 08:15 PM..
effpeetee is offline   Reply With Quote
Old 09-07-2010, 06:26 AM   PM User | #15
Lerura
Regular Coder

 
Lerura's Avatar
 
Join Date: Aug 2005
Location: Denmark
Posts: 869
Thanks: 0
Thanked 112 Times in 111 Posts
Lerura will become famous soon enough
Quote:
Originally Posted by effpeetee View Post
What version above? I'd like to see it.
Oh sorry! by " version above" I meant the div version from my first post:
Code:
<div style="display:table">
  <div style="display:table-row">
    <div style="display:table-cell"></div>
    <div style="display:table-cell"></div>
  </div>
</div>
I styled it with colors and filled the "cells", and omitting <div style="display:table-row"> made no difference to the output, confirming that omitted stages are automatically inserted by CSS.
At least in this simple version

Last edited by Lerura; 09-07-2010 at 06:29 AM..
Lerura is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:42 AM.


Advertisement
Log in to turn off these ads.