Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the background colors of a table cell in reStructuredText?

Following How to use color in text with ReStructured Text (rst2html.py) or how to insert HTML tags without blank lines? I was able to set the background of the text within a table, like this:

.. role:: gbg

.. raw:: html

   <style>
      .gbg {background-color:#00ff00;} 
   </style>

+-------+----------------+-------+---------+-------+---------+
| UTC+1 | (d-s)          | UTC-6 | (zo)    | UTC-7 | (za)    |
+=======+================+=======+=========+=======+=========+
| 15:00 | :gbg:`avail`   |  8:00 |         |  7:00 |         |
+-------+                +-------+---------+-------+         +
| 15:30 |                |  8:30 |         |  7:30 |         |
+-------+----------------+-------+---------+-------+---------+

That results in the word "avail" having a green background behind the letters, but how can I make the entire cell have a colored background instead of just the part of it behind those letters?

like image 584
Zooko Avatar asked Aug 29 '11 21:08

Zooko


2 Answers

Kludge it with javascript:

.. role:: gbg

.. raw:: html

   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
   <script>
     $(document).ready(function() {
       $('.gbg').parent().addClass('gbg-parent');
     });
   </script>
   <style>
      .gbg-parent {background-color:#00ff00;}
   </style>

+-------+----------------+-------+---------+-------+---------+
| UTC+1 | (d-s)          | UTC-6 | (zo)    | UTC-7 | (za)    |
+=======+================+=======+=========+=======+=========+
| 15:00 | :gbg:`avail`   |  8:00 |         |  7:00 |         |
+-------+                +-------+---------+-------+         +
| 15:30 |                |  8:30 |         |  7:30 |         |
+-------+----------------+-------+---------+-------+---------+
like image 101
Tv_ Avatar answered Sep 30 '22 14:09

Tv_


REsT:

.. table::
   :class: rows

   +-------+----------------+-------+---------+-------+---------+
   | UTC+1 | (d-s)          | UTC-6 | (zo)    | UTC-7 | (za)    |
   +=======+================+=======+=========+=======+=========+
   | 15:00 | avail          |  8:00 |         |  7:00 |         |
   +-------+                +-------+---------+-------+         +
   | 15:30 |                |  8:30 |         |  7:30 |         |
   +-------+----------------+-------+---------+-------+---------+

CSS:

table.rows th {
    background-color: #ede;
    border-style: solid solid solid solid;
    border-width: 0px 0px 0px 0px;
    border-color: #AAAAAA;
    text-align: center;
}
table.rows td {
    border-style: solid solid solid solid;
    border-width: 0px 0px 0px 0px;
    border-color: #AAAAAA;
}

table.rows tr {
    border-style: solid solid solid solid;
    border-width: 0px 0px 0px 0px;
    border-color: #AAAAAA;
}

table.rows tr:nth-child(even) {
    background-color: #F3F3FF;
}
table.rows tr:nth-child(odd) {
    background-color: #FFFFEE;
}
like image 30
Adobe Avatar answered Sep 30 '22 12:09

Adobe