473,386 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to use classes to describe data in the table?

103 100+
I would like to vizualize different class variables in the same table in different colors. How to describe this in stylesheet?

For example, the stylesheet which i use now colors both classes in red. I want that day 30 would be blue and day 1 would be red.

Expand|Select|Wrap|Line Numbers
  1.     <style>
  2. table,th,td { border:1px solid black; }
  3. table .mainmonth { color: #000080; }
  4. table .nextmonth { color: #FF0000; }
  5. .error { color: red; }
  6.  
  7. </style>
Expand|Select|Wrap|Line Numbers
  1. <table> 
  2. <tr> 
  3. <td height=17 align="center" > 
  4. <span class="date"  class="mainmonth" >
  5.  <div class="day">30</div> 
  6. <div class="price"><input type="text" name="ad2014-12-29price" size="2" value="" ></div>
  7.  <div class="status"><input type="checkbox" name="ad2014-12-29status"  ></div> </span>
  8.  </td> 
  9. </tr> 
  10. <tr> <td height=17 align="center" > 
  11. <span class="date"  class="nextmonth" >
  12.  <div class="day">1</div> 
  13. <div class="price"><input type="text" name="ad2014-12-29price" size="2" value="" ></div>
  14.  <div class="status"><input type="checkbox" name="ad2014-12-29status"  ></div>
  15.  </span> 
  16. </td> 
  17. </tr> 
  18. </table>
Aug 14 '14 #1

✓ answered by Exequiel

it did not work because you put two class in your element, if you want to use two class or more in one element you can do it this way.
the right way to call a class.
Expand|Select|Wrap|Line Numbers
  1. <span   class="nextmonth date" >
the wrong way.
Expand|Select|Wrap|Line Numbers
  1.  <span   class="nextmonth" class="date" >

15 1678
Rabbit
12,516 Expert Mod 8TB
Give day 1 a different class from day 30.
Aug 14 '14 #2
Exequiel
288 256MB
add this to your css,
Expand|Select|Wrap|Line Numbers
  1. table tr td{background:#00F;}
  2. table tr:nth-child(odd) td{background:#FF0000;}
  3.  
Aug 15 '14 #3
gintare
103 100+
i gave different class, but this does not work. In reality i have a table-calendar. I would like to color class "mainmonth" with blue and class "nextmonth" with red. I do not know how to use class with table in css.

Expand|Select|Wrap|Line Numbers
  1.  table .mainmonth { color: #000080; }
  2. table .nextmonth { color: #FF0000; }
This code colors everything in red.
Aug 15 '14 #4
gintare
103 100+
Dear Exequiel, i need to color more days than given in the example above. Odd or even does not suit. I have assigned class to each day. I would like to color class "mainmonth" with blue and class "nextmonth" with red. I do not know how to use class with table in css.
Expand|Select|Wrap|Line Numbers
  1. table .mainmonth { color: #000080; }
  2. table .nextmonth { color: #FF0000; }
This code colors everything in red.
Aug 15 '14 #5
gintare
103 100+
In the end i did not find out how to use classes. If you know how, please write advice. As a solution it is possible to give style colors for separate td in the table.

Expand|Select|Wrap|Line Numbers
  1. <table>
  2. <tr>
  3. <td height=17 align="center" style="color:red"> <span class="date"   >
  4. <div class="day" >30</div>    
  5. <div class="price"><input type="text" name="ad2014-12-29price" size="2" value="" ></div>  
  6. <div class="status"><input type="checkbox" name="ad2014-12-29status"  ></div>
  7. </span>
  8. </td></tr>
  9. <tr>
  10. <td height=17 align="center" style="color:blue"> <span class="date"   >
  11. <div class="day" >1</div>    
  12. <div class="price"><input type="text" name="ad2014-12-29price" size="2" value="" ></div>  
  13. <div class="status"><input type="checkbox" name="ad2014-12-29status"  ></div>
  14. </span>
  15. </td></tr>
  16. </table>
Aug 15 '14 #6
Exequiel
288 256MB
can you post an image for the output that you want to create? and i will code it in css for you. i cant't get what you mean, are u trying to create a callendar? , , but in css its just easy to use a class,

for example you have a class .mainmonth and .nextmonth in css,
Expand|Select|Wrap|Line Numbers
  1. .mainmonth{background:#red;}
  2. .nextmonth{background:#blue;}
  3.  
you can call or use that by calling each name class in your html element,
Expand|Select|Wrap|Line Numbers
  1. <table class="mainmonth"></table>
  2. <table class="nextmonth"></table>
  3.  
Aug 15 '14 #7
Exequiel
288 256MB
you can try to visit this link. http://www.tutorialspoint.com/css/css_tables.htm
Aug 15 '14 #8
gintare
103 100+
Your example does not work for table element with class. Do not know why.
Tutorial also does not show example how to describe class within table.
It seems that instead of defining a class, i have to define style property inside the table element.
Aug 15 '14 #9
Exequiel
288 256MB
you did not not get the point of the tutorial that i send to you, , I know you don't know how to use class for an element, , That's what i observed. well you need to research more about css/css3 on how to use it, where did you save your css file by the way?
Aug 15 '14 #10
gintare
103 100+
Please see the question description. I use <style> tag, not style file. The class definition simple do not work inside the table.

Expand|Select|Wrap|Line Numbers
  1. <style>
  2.     table,th,td { border:1px solid black; }
  3.     table .mainmonth { color: #000080; }
  4.     table .nextmonth { color: #FF0000; }
  5.     </style>
I ask for syntax, how to describe table class in <style> ? Class applies to <div> or <span> inside <td>.



Expand|Select|Wrap|Line Numbers
  1.  <table> 
  2.     <tr> 
  3.     <td height=17 align="center" > 
  4.     <span class="date"  class="mainmonth" >
  5.      <div class="day">30</div> 
  6.     <div class="price"><input type="text" name="ad2014-12-29price" size="2" value="" ></div>
  7.      <div class="status"><input type="checkbox" name="ad2014-12-29status"  ></div> </span>
  8.      </td> 
  9.     </tr> 
  10.     <tr> <td height=17 align="center" > 
  11.     <span class="date"  class="nextmonth" >
  12.      <div class="day">1</div> 
  13.     <div class="price"><input type="text" name="ad2014-12-29price" size="2" value="" ></div>
  14.      <div class="status"><input type="checkbox" name="ad2014-12-29status"  ></div>
  15.      </span> 
  16.     </td> 
  17.     </tr> 
  18.     </table>
Aug 15 '14 #11
gintare
103 100+
The first solution was to define style in the td element like
Expand|Select|Wrap|Line Numbers
  1. <td height=17 align="center" style="color:blue">.
The second solution is to use class in td element. When i use class for inner td elements "div" or "span", it is not working. But if i define class in td, when table cells are colored.
Expand|Select|Wrap|Line Numbers
  1. <style> .mainmonth { color: #000080; } </style>
  2. <td height=17 align="center" class="mainmonth">
Aug 15 '14 #12
Exequiel
288 256MB
it did not work because you put two class in your element, if you want to use two class or more in one element you can do it this way.
the right way to call a class.
Expand|Select|Wrap|Line Numbers
  1. <span   class="nextmonth date" >
the wrong way.
Expand|Select|Wrap|Line Numbers
  1.  <span   class="nextmonth" class="date" >
Aug 15 '14 #13
Exequiel
288 256MB
by the wayi created some tuts on how to use css for element using class. I hope it helps, just observed the elements and the class i called, better to copy paste this code and save this as a html file and run to see for your self.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6.  
  7. <style>
  8. table.table{border:1px solid #000;}/*must be call by table only*/
  9. table.table tr td{color:#990000;}/*for all td element inside the table and tr*/
  10. table.table tr td.withborder{border:1px solid #666; color:#0000FF;}/*must be inside of table element and tr and call by td*/
  11.  
  12. div.div{background:red;}/*must be call by div only*/
  13. div.div .child{border:#999; background:#000000; color:#FFFFFF;}
  14.  
  15. .universal{background:#CCC; border-radius:5px;}/*can call by any element*/
  16. .someclass{border:1px solid #0CC;}/*can call by any element*/
  17. .red{color:#F00;}/*can call by any element*/
  18. .padding{padding:5px;}/*can call by any element*/
  19.  
  20. div{padding:5px;} /*if you put div element the style of this css div will adopt by all div div*/
  21. </style>
  22.  
  23. </head>
  24.  
  25. <body>
  26. <h2>Calling class to the right element</h2>
  27. <table class="table">
  28.     <tr>
  29.         <td>For table only</td>
  30.         <td class="withborder">with class withborder</td>
  31.         <td>For table only</td>
  32.     </tr>
  33. </table>
  34. <br>
  35.     <div class="div">For div only</div>
  36. <br>
  37.     <div class="div">
  38.         div with child element.
  39.         <div class="child">i'm the child</div>
  40.     </div>
  41. <br>
  42.     <div class="universal"><b>universal</b> universal class, You can call me to any element</div>
  43. <br>
  44. <table class="universal">
  45.     <tr>
  46.         <td>universal class called by table element.</td>
  47.     </tr>
  48. </table>
  49. <br>
  50.  
  51. <h2>wrong css call by elements.</h2>
  52.  
  53. <b>the class table call by an element div.</b>
  54. <div class="table">The class <b>table</b> didnot work for this element because you declare on your css that the table class is ony for the elelemnt table. [table.table{}] if you put only in the css like this [.table] it will adopt by any elelemnts as long as you call this class,  </div>
  55. <br>
  56. <b>the class div call by an element table.</b>
  57. <table class="div">
  58.     <tr>
  59.         <td>div class for table didnot work, </td>
  60.     </tr>
  61. </table>
  62.  
  63. <h2>How to call multiple class in one element.</h2>
  64. <div class="div universal someclass">I have 3 class</div>
  65. <div class="universal  red padding">I have 3  class</div>
  66.  
  67. <table class="table universal someclass red padding">
  68.     <tr>
  69.         <td>the table with 5 class.</td>
  70.     </tr>
  71. </table>
  72. </body>
  73. </html>
  74.  
  75.  
I hope it helps.
Aug 15 '14 #14
gintare
103 100+
Thanks. Now it works!
Aug 16 '14 #15
Exequiel
288 256MB
your welcome, good luck. :)
Aug 16 '14 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Manuel | last post by:
I want to describe a table of a database in XML flavour and I would like to know if there is some 'standard' schema to pick as example to produce my .xml definition file. PS: I'll work with PHP...
1
by: Kevin Myers | last post by:
Hello, I'm an experienced application developer in some languages (including various SQL dialects), but have very little experience with MS Access or VBA, and am having trouble figuring out how...
2
by: Steve Stover | last post by:
I want to use the caching API in .net to store data. The data would be stored in a data table class that has approx. 10 columns and 71 rows. What I need to know is this: According to Microsoft's...
2
by: Brian Mitchell | last post by:
Ok, I know this is an elementary question but I have a data grid that is bound to a data table and I can't seem to find a way to match the selected row in the grid with it's respective row in the...
11
by: Ron L | last post by:
I have a data table that lists a series of items in my database. In my user form, I want the user to be able to filter by a number of criteria (e.g. location, contract, date modified, etc). Other...
1
by: John | last post by:
Hi When using Table Adapter Configuration Wizard if 'Use SQL Statements' is selected as Command Type, the data table's name in dataset is retained and only its data adapter's select statements...
1
by: laredotornado | last post by:
Hi, I have a data table on my page (buried amidst other images and extraneous text). I would like to spawn a new window that automatically prints the content of my data table, and only that...
12
by: Serman D. | last post by:
Hi all, How do I describe non-table objects, like UDF functions and procedures, using db2's normal command line interface? Database server = DB2/LINUX 9.1.0 Express-C running on Linux 2.6...
4
by: indona | last post by:
hi, i have to enter data from a delimited file into sqlserver database table. i have been able to delimit the file and read the data into a data table, now i want enter the data table contents to...
1
by: BaseballGraphs | last post by:
Hello, I am trying to divide one value from my data table with an associated ID by another value from my data table with a different ID for the same day that the value was added to the data table....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.