LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-29-2005, 08:16 AM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
how can CSS styles be aplied on different TRs of a table?


I'm working on a WEB Application. I have to apply different styles to different rows of a table. Haw can that be achieved?

Code:
<tr class="style1">
  <td>Style 1</td>
  <td>blah</td>
</tr>
<tr class="style2">
  <td>Style 2</td>
  <td>blah</td>
</tr>
<tr class="style1">
  <td>Style 1 <b>again</b></td>
  <td>blah</td>
</tr>
How do I have to define those two styles in the CSS?
 
Old 03-29-2005, 08:21 AM   #2
ror
Member
 
Registered: May 2004
Distribution: Ubuntu
Posts: 583

Rep: Reputation: 33
The same way you'd set rules for any class in CSS, with .style1 etc
 
Old 03-29-2005, 09:08 AM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Also some browsers like Safari (from Apple) just won't take in account tr's styles
 
Old 03-29-2005, 09:11 AM   #4
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
But I've given it some tries and it doesn't work. :'(

I'll give you a list:
#style1 {}
#table.style1 {}
#tr.style1 {}

None of them worked. What am I missing?
 
Old 03-29-2005, 09:19 AM   #5
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
With no visual values, how do you know that it does not work in your browser ?
try something like
Code:
style1 { background-color: blue; color: white;}
table.style1 {background-color: red; color: yellow;}
tr.style1 {background-color: white; color: black;}
 
Old 03-29-2005, 09:32 AM   #6
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
I mean.. those are the ones I tried (with visual values) LOL.

color and background-color.

Let me give yours a try anyway. Will write back after I give it a try.
 
Old 03-29-2005, 09:41 AM   #7
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Nope... none of them worked. What could I be missing?
 
Old 03-29-2005, 09:49 AM   #8
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
What is your browser ?
 
Old 03-29-2005, 10:17 AM   #9
okmyx
Member
 
Registered: May 2004
Location: Cornwall, UK
Distribution: Ubuntu 8.04
Posts: 464

Rep: Reputation: 31
You probably need to apply the styles to the td's rather than the tr's. tr's don't have any font/colour attributes linked to them probably only border and padding attributes.
 
Old 03-29-2005, 12:37 PM   #10
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Mozilla

That makes sense. I'll try with the TDs (though it's a longer pain in the ass :'().

Tell you about it in a minute.
 
Old 03-29-2005, 12:48 PM   #11
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90

Nope... nothing.

I have now:
#style1
#table.style1
#td.style1
#style1.td

All with different styles (just in case). None works.

Last edited by eantoranz; 03-29-2005 at 12:55 PM.
 
Old 03-29-2005, 01:03 PM   #12
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Partial solution:

I have to set the id of the table.
Code:
<table id="aID">
  <tr>
    <td class="style1">Blah!</td>
  </tr>
</table>
and the style sheet says:
Code:
#aID td.style1 {}
Let me try with tr. Will tell you in a while (I have to go eat some birthday cake RIGHT NOW!!!!)
 
Old 03-29-2005, 01:24 PM   #13
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
It works at the tr level too.

That will make a solution.... however, you think there's a way to do it without setting the tables ID?
 
Old 03-29-2005, 01:41 PM   #14
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
For my part, due to browser incompatibility reason I avoid using style in trs

But this should work with mozilla :
Code:
<table>
  <tr class="style1">
    <td>Blah!</td>
  </tr>
</table>
witth style1 like
Code:
tr.style1 { background-color: red; }
 
Old 03-29-2005, 01:47 PM   #15
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Will give it another shot later. Tell you about the results when I do... but don't hold your breath, cause I'm working on something else right now.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
new qt styles? isl01jbe Linux - Software 1 03-26-2009 04:44 AM
micrografx trs extension leosgb Linux - Software 0 05-22-2005 08:26 PM
Styles and Such RySk8er30 Mandriva 6 04-23-2005 02:50 PM
MySQL non-realtime table-by-table mirroring Passive Linux - Software 1 01-20-2004 12:11 PM
How to import MS ACCESS Table including OLE filed into the MySQL Table ? myunicom Linux - General 1 11-28-2003 11:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration