Connecting Tech Pros Worldwide Help | Site Map

Zebra Table

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 29th, 2008, 08:15 PM
Bruce A. Julseth
Guest
 
Posts: n/a
Default Zebra Table

I am trying to create a Zebra table where each Zebra "Strip" consists of two
rows. I am using a classical table to create the Zebra table. In my CSS, I
have

..dark {
background-color: #00FFFF;
}

..light {
background-color: #CCFFFF;
}

<tr class="light ">
<td class="name">Name</td>
<td class="addr">Street</td>
<td class="email">Email</td>
<td class="interest">Interests</td>
</tr>
<tr class="light ">
<td>Spouse</td>
<td>Telephone</td>
<td>Spouse Email</td>
<td>Spouse Interests</td>
</tr>

<tr class="dark">
<td class="name">Joe</td>
<td class="addr">Elm</td>
<td class="email">Something</td>
<td class="interest">More</td>
</tr>
<tr class="dark">
<td>Jane</td>
<td>999 999-9999</td>
<td>Something Email</td>
<td>Something Interests</td>
</tr>

I would to wrap the two rows in a single definition, like with a <divor a
<spanbut having been able to make that work.

<div class="light">
<tr>
<td class="name">Name</td>
<td class="addr">Street</td>
<td class="email">Email</td>
<td class="interest">Interests</td>
</tr>
<tr class="light ">
<td>Spouse</td>
<td>Telephone</td>
<td>Spouse Email</td>
<td>Spouse Interests</td>
</tr>
</div>

<div class="dark">
<tr>
<td class="name">Joe</td>
<td class="addr">Elm</td>
<td class="email">Something</td>
<td class="interest">More</td>
</tr>
<tr class="dark">
<td>Jane</td>
<td>999 999-9999</td>
<td>Something Email</td>
<td>Something Interests</td>
</tr>
</div>

Appreciate your help. Thanks...

Bruce



  #2  
Old July 29th, 2008, 08:25 PM
Bruce A. Julseth
Guest
 
Posts: n/a
Default Re: Zebra Table


"Bruce A. Julseth" <julebj_nospam@bellsouth.netwrote in message
news:gNKjk.709$XT1.505@bignews5.bellsouth.net...
Quote:
>I am trying to create a Zebra table where each Zebra "Strip" consists of
>two rows. I am using a classical table to create the Zebra table. In my
>CSS, I have
>
.dark {
background-color: #00FFFF;
}
>
.light {
background-color: #CCFFFF;
}
>
<tr class="light ">
<td class="name">Name</td>
<td class="addr">Street</td>
<td class="email">Email</td>
<td class="interest">Interests</td>
</tr>
<tr class="light ">
<td>Spouse</td>
<td>Telephone</td>
<td>Spouse Email</td>
<td>Spouse Interests</td>
</tr>
>
<tr class="dark">
<td class="name">Joe</td>
<td class="addr">Elm</td>
<td class="email">Something</td>
<td class="interest">More</td>
</tr>
<tr class="dark">
<td>Jane</td>
<td>999 999-9999</td>
<td>Something Email</td>
<td>Something Interests</td>
</tr>
>
I would to wrap the two rows in a single definition, like with a <divor
a <spanbut having been able to make that work.
>
<div class="light">
<tr>
<td class="name">Name</td>
<td class="addr">Street</td>
<td class="email">Email</td>
<td class="interest">Interests</td>
</tr>
<tr class="light ">
<td>Spouse</td>
<td>Telephone</td>
<td>Spouse Email</td>
<td>Spouse Interests</td>
</tr>
</div>
>
<div class="dark">
<tr>
<td class="name">Joe</td>
<td class="addr">Elm</td>
<td class="email">Something</td>
<td class="interest">More</td>
</tr>
<tr class="dark">
<td>Jane</td>
<td>999 999-9999</td>
<td>Something Email</td>
<td>Something Interests</td>
</tr>
</div>
>
Appreciate your help. Thanks...
>
Bruce
>
I think I found the solution..

Adding

span.dark tr {
background-color: #00FFFF;

}

span.light tr {
background-color: #CCFFFF;
}

seems to be doing the trick.. Thanks...


  #3  
Old July 29th, 2008, 08:35 PM
Bruce A. Julseth
Guest
 
Posts: n/a
Default Re: Zebra Table


"Bruce A. Julseth" <julebj_nospam@bellsouth.netwrote in message
news:ZVKjk.713$XT1.151@bignews5.bellsouth.net...
Quote:
>
"Bruce A. Julseth" <julebj_nospam@bellsouth.netwrote in message
news:gNKjk.709$XT1.505@bignews5.bellsouth.net...
Quote:
>>I am trying to create a Zebra table where each Zebra "Strip" consists of
>>two rows. I am using a classical table to create the Zebra table. In my
>>CSS, I have
>>
>.dark {
>background-color: #00FFFF;
>}
>>
>.light {
>background-color: #CCFFFF;
>}
>>
> <tr class="light ">
> <td class="name">Name</td>
> <td class="addr">Street</td>
> <td class="email">Email</td>
> <td class="interest">Interests</td>
> </tr>
> <tr class="light ">
> <td>Spouse</td>
> <td>Telephone</td>
> <td>Spouse Email</td>
> <td>Spouse Interests</td>
> </tr>
>>
> <tr class="dark">
> <td class="name">Joe</td>
> <td class="addr">Elm</td>
> <td class="email">Something</td>
> <td class="interest">More</td>
> </tr>
> <tr class="dark">
> <td>Jane</td>
> <td>999 999-9999</td>
> <td>Something Email</td>
> <td>Something Interests</td>
> </tr>
>>
>I would to wrap the two rows in a single definition, like with a <divor
>a <spanbut having been able to make that work.
>>
><div class="light">
> <tr>
> <td class="name">Name</td>
> <td class="addr">Street</td>
> <td class="email">Email</td>
> <td class="interest">Interests</td>
> </tr>
> <tr class="light ">
> <td>Spouse</td>
> <td>Telephone</td>
> <td>Spouse Email</td>
> <td>Spouse Interests</td>
> </tr>
></div>
>>
><div class="dark">
> <tr>
> <td class="name">Joe</td>
> <td class="addr">Elm</td>
> <td class="email">Something</td>
> <td class="interest">More</td>
> </tr>
> <tr class="dark">
> <td>Jane</td>
> <td>999 999-9999</td>
> <td>Something Email</td>
> <td>Something Interests</td>
> </tr>
></div>
>>
>Appreciate your help. Thanks...
>>
>Bruce
>>
>
I think I found the solution..
>
Adding
>
span.dark tr {
background-color: #00FFFF;
>
}
>
span.light tr {
background-color: #CCFFFF;
}
>
seems to be doing the trick.. Thanks...
>
Nope.. It didn't work.. Sorry. Can someone out there in CSS land help me?

Thanks and sorry for the false alarm. It worked fine in Dreamweaver, but
failed in Safari both on my localhost and when I upload it.


  #4  
Old July 29th, 2008, 08:45 PM
Johannes Koch
Guest
 
Posts: n/a
Default Re: Zebra Table

Bruce A. Julseth schrieb:
Quote:
"Bruce A. Julseth" <julebj_nospam@bellsouth.netwrote in message
news:gNKjk.709$XT1.505@bignews5.bellsouth.net...
Quote:
Quote:
> <tr class="light ">
> <td class="name">Name</td>
> <td class="addr">Street</td>
> <td class="email">Email</td>
> <td class="interest">Interests</td>
> </tr>
> <tr class="light ">
> <td>Spouse</td>
> <td>Telephone</td>
> <td>Spouse Email</td>
> <td>Spouse Interests</td>
> </tr>
Looks like these are header cells. So use the th element!
Quote:
Quote:
> <tr class="dark">
> <td class="name">Joe</td>
> <td class="addr">Elm</td>
> <td class="email">Something</td>
> <td class="interest">More</td>
> </tr>
> <tr class="dark">
> <td>Jane</td>
> <td>999 999-9999</td>
> <td>Something Email</td>
> <td>Something Interests</td>
> </tr>
It can/will be difficult for a screen reader user to find out which
column header cells belong to which data cell. You can associate them
via td/@headers and th/@id.
Quote:
Quote:
><div class="dark">
> <tr>
> <td class="name">Joe</td>
> <td class="addr">Elm</td>
> <td class="email">Something</td>
> <td class="interest">More</td>
> </tr>
> <tr class="dark">
> <td>Jane</td>
> <td>999 999-9999</td>
> <td>Something Email</td>
> <td>Something Interests</td>
> </tr>
></div>
Neither can div be a parent element of tr, ...
Quote:
I think I found the solution..
>
Adding
>
span.dark tr {
background-color: #00FFFF;
>
}
.... nor can span.

However, tbody can.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
  #5  
Old July 29th, 2008, 09:15 PM
Bruce A. Julseth
Guest
 
Posts: n/a
Default Re: Zebra Table


"Johannes Koch" <koch@w3development.dewrote in message
news:488f80e0$0$4244$6e1ede2f@read.cnntp.org...
Quote:
Bruce A. Julseth schrieb:
Quote:
>"Bruce A. Julseth" <julebj_nospam@bellsouth.netwrote in message
>news:gNKjk.709$XT1.505@bignews5.bellsouth.net.. .
>
Quote:
Quote:
>> <tr class="light ">
>> <td class="name">Name</td>
>> <td class="addr">Street</td>
>> <td class="email">Email</td>
>> <td class="interest">Interests</td>
>> </tr>
>> <tr class="light ">
>> <td>Spouse</td>
>> <td>Telephone</td>
>> <td>Spouse Email</td>
>> <td>Spouse Interests</td>
>> </tr>
>
Looks like these are header cells. So use the th element!
>
Quote:
Quote:
>> <tr class="dark">
>> <td class="name">Joe</td>
>> <td class="addr">Elm</td>
>> <td class="email">Something</td>
>> <td class="interest">More</td>
>> </tr>
>> <tr class="dark">
>> <td>Jane</td>
>> <td>999 999-9999</td>
>> <td>Something Email</td>
>> <td>Something Interests</td>
>> </tr>
>
It can/will be difficult for a screen reader user to find out which column
header cells belong to which data cell. You can associate them via
td/@headers and th/@id.
>
Quote:
Quote:
>><div class="dark">
>> <tr>
>> <td class="name">Joe</td>
>> <td class="addr">Elm</td>
>> <td class="email">Something</td>
>> <td class="interest">More</td>
>> </tr>
>> <tr class="dark">
>> <td>Jane</td>
>> <td>999 999-9999</td>
>> <td>Something Email</td>
>> <td>Something Interests</td>
>> </tr>
>></div>
>
Neither can div be a parent element of tr, ...
>
Quote:
>I think I found the solution..
>>
>Adding
>>
>span.dark tr {
> background-color: #00FFFF;
>>
>}
>
... nor can span.
>
However, tbody can.
>
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Thanks for the suggestion on using <th>. I've never used tbody so I'll have
to study how to use it, as well as td/@headers and th/@id.
..
Hope this helps. If anyone else has a suggestion, please send them to me.

Bruce


  #6  
Old July 29th, 2008, 10:15 PM
Johannes Koch
Guest
 
Posts: n/a
Default Re: Zebra Table

Bruce A. Julseth schrieb:
Quote:
Thanks for the suggestion on using <th>. I've never used tbody so I'll have
to study how to use it, as well as td/@headers and th/@id.
See the chapter on tables
(<http://www.w3.org/TR/html4/struct/tables.html>) in the HTML 4.01
specification for tbody
(<http://www.w3.org/TR/html4/struct/tables.html#h-11.2.3>), th/@id and
td/@headers (<http://www.w3.org/TR/html4/struct/tables.html#h-11.4.1>).

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
  #7  
Old July 29th, 2008, 10:15 PM
Nik Coughlin
Guest
 
Posts: n/a
Default Re: Zebra Table

"Bruce A. Julseth" <julebj_nospam@bellsouth.netwrote in message
news:gNKjk.709$XT1.505@bignews5.bellsouth.net...
Quote:
>I am trying to create a Zebra table where each Zebra "Strip" consists of
>two rows.
No need to set the classes on all the <tr>s, just the odd ones is enough.
Style the <td>s not the <tr>s.

<table class="zebra">
<tr class="light">
<td>Blah</td>
</tr>
<tr class="light">
<td>Blah</td>
</tr>
<tr>
<td>Blah</td>
</tr>
<tr>
<td>Blah</td>
</tr>
</table>

..zebra td {
background-color: #CCFFFF;
}

..zebra .light td {
background-color: #00FFFF;
}

  #8  
Old July 29th, 2008, 11:55 PM
dorayme
Guest
 
Posts: n/a
Default Re: Zebra Table

In article <g6o4ls$k30$1@registered.motzarella.org>,
"Nik Coughlin" <nrkn.com@gmail.comwrote:
Quote:
"Bruce A. Julseth" <julebj_nospam@bellsouth.netwrote in message
news:gNKjk.709$XT1.505@bignews5.bellsouth.net...
Quote:
I am trying to create a Zebra table where each Zebra "Strip" consists of
two rows.
>
No need to set the classes on all the <tr>s, just the odd ones is enough.
Style the <td>s not the <tr>s.
>
....

As Nick shows, it is easy enough to implement with just css.
Depending on the nature of your table - how much would be lost if there
were no stripes if js were disabled or unavailable in rare cases - you
might also consider a javascript solution. It saves a lot of bother if
the table is big and changes a lot or if it is generated via php from
csv files on the server.

There is an example of this at

<http://khs.org.au/historian_database/tz.htmland the js at

<http://khs.org.au/historian_database/table_row_stripe.js>

You would need to adapt to your two rows at a time requirements.

--
dorayme
  #9  
Old July 30th, 2008, 02:05 AM
Bruce A. Julseth
Guest
 
Posts: n/a
Default Re: Zebra Table


"dorayme" <doraymeRidThis@optusnet.com.auwrote in message
news:doraymeRidThis-CE3066.09453030072008@news-vip.optusnet.com.au...
Quote:
In article <g6o4ls$k30$1@registered.motzarella.org>,
"Nik Coughlin" <nrkn.com@gmail.comwrote:
>
Quote:
>"Bruce A. Julseth" <julebj_nospam@bellsouth.netwrote in message
>news:gNKjk.709$XT1.505@bignews5.bellsouth.net.. .
Quote:
>I am trying to create a Zebra table where each Zebra "Strip" consists of
>two rows.
>>
>No need to set the classes on all the <tr>s, just the odd ones is enough.
>Style the <td>s not the <tr>s.
>>
...
>
As Nick shows, it is easy enough to implement with just css.
Depending on the nature of your table - how much would be lost if there
were no stripes if js were disabled or unavailable in rare cases - you
might also consider a javascript solution. It saves a lot of bother if
the table is big and changes a lot or if it is generated via php from
csv files on the server.
>
There is an example of this at
>
<http://khs.org.au/historian_database/tz.htmland the js at
>
<http://khs.org.au/historian_database/table_row_stripe.js>
>
You would need to adapt to your two rows at a time requirements.
>
--
dorayme
The <tbodysolutions does exactly what I want... BUT, I do have frequent
changes which make updating the table a 'bear!' So the JS suggestion is
welcomed. I had read about it somewhere. Thank to pointing me to an example.

Bruce


  #10  
Old July 30th, 2008, 02:45 AM
dorayme
Guest
 
Posts: n/a
Default Re: Zebra Table

In article <WUPjk.915$Ep1.505@bignews2.bellsouth.net>,
"Bruce A. Julseth" <julebj_nospam@bellsouth.netwrote:
Quote:
"dorayme" <doraymeRidThis@optusnet.com.auwrote in message
Quote:
Quote:
You would need to adapt to your two rows at a time requirements.
Quote:
I do have frequent
changes which make updating the table a 'bear!' So the JS suggestion is
welcomed. I had read about it somewhere. Thank to pointing me to an example.
>
If you have frequent changes, you might consider letting some PHP build
your table from a simple csv file (which is just a text file that has
the data with commas after each item, row by row to correspond to tr).
Easier to maintain.

You make the HTML file with a bit of php in place of the table. Put it
on the server along with a plain text file .csv. I do this now and then
and it is quite a time saver. It is especially decent in that it lets a
client prepare the spreadsheet and export to csv format. And you, the
webmaster, simply upload the csv file (or you can get the client to do
this... but it is nice to keep a 'professional' eye on things, one must
be wary of giving clients too much power. They can get ideas that they
can do without you and then how do you pay advance tax bills?)

--
dorayme
  #11  
Old July 31st, 2008, 07:25 PM
Bruce A. Julseth
Guest
 
Posts: n/a
Default Re: Zebra Table


"dorayme" <doraymeRidThis@optusnet.com.auwrote in message
news:doraymeRidThis-D221F1.12395930072008@news-vip.optusnet.com.au...
Quote:
In article <WUPjk.915$Ep1.505@bignews2.bellsouth.net>,
"Bruce A. Julseth" <julebj_nospam@bellsouth.netwrote:
>
Quote:
>"dorayme" <doraymeRidThis@optusnet.com.auwrote in message
>
Quote:
Quote:
You would need to adapt to your two rows at a time requirements.
>
>
Quote:
>I do have frequent
>changes which make updating the table a 'bear!' So the JS suggestion is
>welcomed. I had read about it somewhere. Thank to pointing me to an
>example.
>>
>
If you have frequent changes, you might consider letting some PHP build
your table from a simple csv file (which is just a text file that has
the data with commas after each item, row by row to correspond to tr).
Easier to maintain.
>
You make the HTML file with a bit of php in place of the table. Put it
on the server along with a plain text file .csv. I do this now and then
and it is quite a time saver. It is especially decent in that it lets a
client prepare the spreadsheet and export to csv format. And you, the
webmaster, simply upload the csv file (or you can get the client to do
this... but it is nice to keep a 'professional' eye on things, one must
be wary of giving clients too much power. They can get ideas that they
can do without you and then how do you pay advance tax bills?)
>
--
dorayme
Thanks for the suggestion. I'll take a look at doing just that.

Bruce


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.