View Full Version : Replace a table with CSS
Hi, as the regulars over at INETPUB would know I am presently going through a Web Site Design course (http://www.vlepub.sa.edu.au/xml/courses/Course_2006BEGDFN.aspx). At the moment I am finishing off the third assignment based on Cascading Style Sheets.
The Project requirements are that I take a site (http://www.tvicomputing.com/studentwebs/group1/student4/home.html) (previously created in Assignment 2) and convert it from Table-based layout to pure CSS layout.
So far I have achieved that plus the rest of the required enhancements and posted it on the site (http://www.tvicomputing.com/studentwebs/group1/student4/home3.html) but I am still worried about leaving in one table used to show pricing data on the Produce (http://www.tvicomputing.com/studentwebs/group1/student4/produce3.html) page.
Anybody able to give me a clue about transforming this table into CSS?
I have been pushing this through too many late nights and I think I have CRAFT syndrome ;)
Daudio
08-21-2005, 07:32 AM
Ian,
<< but I am still worried about leaving in one table used to show pricing data >>
Do you have to ? That looks to be an appropriate use of a Table: to present tablular data !
Dave
ktinkel
08-21-2005, 11:02 AM
The Project requirements are that I take a site (http://www.tvicomputing.com/studentwebs/group1/student4/home.html) (previously created in Assignment 2) and convert it from Table-based layout to pure CSS layout.
So far I have achieved that plus the rest of the required enhancements and posted it on the site (http://www.tvicomputing.com/studentwebs/group1/student4/home3.html) but I am still worried about leaving in one table used to show pricing data on the Produce (http://www.tvicomputing.com/studentwebs/group1/student4/produce3.html) page.
Anybody able to give me a clue about transforming this table into CSS?I agree with Dave — this is exactly what tables are made for. But I have seen some of your comments on this course, but it was an interesting puzzle so I thought I would try to recreate your table in CSS.
I am definitely no Lois, Dennis, or Kelvyn, but can usually finagle things in the end. This was difficult; had to use pixel dimensions as percentages were not working. (I am sure someone could make them work — just not me!) I feel as if I have too many DIVs, but each one solved a problem. Anyway, FWIW, it appears it can be done. Should it? Yes, for a good grade in your course! <g>
See my attachment to see how close I came (heights are off a bit; sorry). And here is the code I used:
::::::::::::: CSS :::::::::::::::::
<style type="text/css">
body {
background-color: dcffde;
color: 336600;
font-size: 16px;
margin-top: 8em;
}
.bigbox {
width: 580px;
height: 188px;
margin: 2px auto;
border: 4px solid #c1d1b2;
border-right: 4px solid #004700;
border-bottom: 4px solid #004700;
}
.innerbox { width: 576px; margin: 2px auto; }
.items {
float: left;
width: 334px;
height: 22px;
width: 330px;
padding-right: 2px;
}
.prices {
float: left;
text-align: center;
width: 243px;
}
p {
margin: 0 1px 2px 1px;
padding: 4px;
border: 1px solid #004700;
border-right: 1px solid #c1d1b2;
border-bottom: 1px solid #c1d1b2;
}
</style>
</head>
<body>
<div class="bigbox">
<div class="innerbox">
<div class="items">
<p><strong>Item</strong> </p>
<p>Alfalfa sprouts </p>
<p>Apples, Bonza </p>
<p>Apples, Golden Delicious </p>
<p>Artichoke hearts. pickled </p>
<p>Avocados, dark, large </p>
</div>
<div class="prices">
<p><strong>Price</strong> </p>
<p>$1.50 per punnet </p>
<p>$5.99 per Kg </p>
<p>$4.99 per Kg </p>
<p>$17.99 per Kg </p>
<p>2 for $3.50 </p>
</div>
</div>
</div>
Do you have to ? That looks to be an appropriate use of a Table: to present tablular data !I agree but I am doing this just in case it is expected to have a completely table-free site.
In INETPUB Judy pointed me to this great resource on W3C:The CSS table model (http://www.w3.org/TR/CSS21/tables.html#q2)
I had no idea that anything like this was available. See my other reply for how I finally made a table-free table LOL
(http://www.w3.org/TR/CSS21/tables.html#q2)
Hi Kathleen, that is an impressive Table-free table and I love the way you got the border by using different sized boxes. Might try that because it seems a better way to get the borders right.
After sitting up into the wee smalls pondering how to do it.
Here is what I did after finding a clue on a mailing list thanks to Google.
<div class="cellblock"><!-- This wraps the cellblock and provides a left margin to help center the block -->
<!-- Header cells with Left borders: T,L,B and Right borders: T,R,L,B -->
<div class="topcell-L">Item</div><div class="topcell-R">Price</div><br clear="left">
<!-- data cells with Left borders: L,B and Right borders: R,L,B -->
<div class="cell-L">Alfalfa sprouts</div><div class="cell-R">$1.50 per punnet</div><br clear="left">
<div class="cell-L">Apples, Bonza</div><div class="cell-R">$5.99 per Kg</div><br clear="left">
<div class="cell-L">Apples, Golden Delicious</div><div class="cell-R">$4.99 per Kg</div><br clear="left">
<div class="cell-L">Artichoke hearts. pickled</div><div class="cell-R">$17.99 per Kg</div><br clear="left">
<!-- data cell with closing thicker borders, Left borders: L,B and Right borders: R,L,B -->
<div class="cell-LB">Avocados, dark, large</div><div class="cell-RB">2 for $3.50</div><br clear="left">
</div>
Because of the complexity I made a separate stylesheet which is called in only by the Produce page. I called it Cellblock.
/* This stylesheet has been designed for Joe's Online Shop */
/* by Ian Loxton and last updated at 01:51, 22 August 2005 */
/* This is an extra sheet supporting just the cellblock elements */
/* I certify that this sheet this is all my own work */
.cellblock {
float: none;
margin-left: 2%;
}
.topcell-L { /* heading cell with borders at top and left */
float: left;
width: 47%; /* allows for IE to botch up the widths due to the padding values */
font-weight : bold;
border-left : medium solid #b2d8b2;
border-top : medium solid #b2d8b2;
border-bottom : medium solid #b2d8b2;
text-align: left;
padding-left: 2%;
}
.topcell-R { /* heading cell with borders at top, left and right */
float: left;
width: 48%;
border-top : medium solid #b2d8b2;
border-bottom :medium solid #b2d8b2;
border-right: medium solid #b2d8b2;
border-left : thin solid #b2d8b2;
font-weight : bold;
text-align: center;
}
.cell-L { /* data cell with borders at bottom and left */
float: left;
width: 47%; /* allows for IE to botch up the widths due to the padding values */
border-left : medium solid #b2d8b2;
border-bottom : thin solid #b2d8b2;
text-align: left;
padding-left: 2%;
}
.cell-R { /* data cell with borders at left, bottom and right */
float: left;
width: 48%;
border-left : thin solid #b2d8b2;
border-bottom : thin solid #b2d8b2;
border-right: medium solid #b2d8b2;
text-align: center;
}
.cell-LB { /* bottom row data cell with borders at bottom and left */
float: left;
width: 47%; /* allows for IE to botch up the widths due to the padding values */
border-left : medium solid #b2d8b2;
border-bottom : medium solid #b2d8b2;
text-align: left;
padding-left: 2%;
}
.cell-RB { /* bottom row data cell with borders at left, bottom and right */
float: left;
width: 48%;
border-left : thin solid #b2d8b2;
border-bottom: medium solid #b2d8b2;
border-right: medium solid #b2d8b2;
text-align: center;
}
So far it works fine in IE 6, FF 1.06 and Opera 8.0 and at resolutions from 640 up to 1280. I don't have the older browsers to try it out but the page verifies as HTML 4.01 and the CSS verifies as well.
It isn't anywhere near as pretty as the W3C stuff or your solution but hey, it works!
(PS: this is a copy of my post in INETPUB)
ktinkel
08-21-2005, 04:11 PM
Hi Kathleen, that is an impressive Table-free table and I love the way you got the border by using different sized boxes. Might try that because it seems a better way to get the borders right.
After sitting up into the wee smalls pondering how to do it.
Here is what I did .… So far it works fine in IE 6, FF 1.06 and Opera 8.0 and at resolutions from 640 up to 1280. I don't have the older browsers to try it out but the page verifies as HTML 4.01 and the CSS verifies as well.
It isn't anywhere near as pretty as the W3C stuff or your solution but hey, it works!
(PS: this is a copy of my post in INETPUB)Interesting. I actually got kind of hung up trying to replicate your borders.
Anyway, so long as you ace your class! Good luck with it.
Anyway, so long as you ace your class!Thanks Kathleen. Lecturer has just seen the site and given me a Credit, that's before he saw the work just done on making a table-free table. The learning wasn't wasted, I now have several ideas on how to replicate tables. Even that stuff from W3C looks interesting though I would like a Tutorial on it if there was one.
Now it is on with the show, this week we learn and use JavaScript <sigh>
Standby for the questions ;)
ktinkel
08-22-2005, 07:07 AM
… this week we learn and use JavaScript <sigh>
Standby for the questions ;)Uh-oh! [ducking] <g>
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.