I'd like to make an IPA vowel diagram like this one:
I have made a table with 7 rows and 5 columns in HTML, but how do I change the shape of the table to trapezoid using CSS?
I know that it's possible to draw a trapezoid in a graphics editor and then use the resulting image as a background in HTML, but I'd like to do do this with pure CSS if possible.
<table>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
</tr>
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
<tr>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
</tr>
<tr>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
</tr>
<tr>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
</tr>
<tr>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
</tr>
<tr>
<td>31</td>
<td>32</td>
<td>33</td>
<td>34</td>
<td>35</td>
</tr>
</table>
you can use css like this to make shapes and build the table. Is dont think there i an other way to be honest.
#trapezoid {
border-bottom: 100px solid red;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
height: 0;
width: 100px;
}
next time try to show us what you DID try to get the result.
I think that the closest that you can get with CSS is using some 3d perspective:
table {
transform: translate(100px, 130px) perspective(200px) rotateX(-40deg);
transform-origin: bottom right;
transform-style: preserve-3d;
}
td,
th {
transform: rotateX(40deg);
backface-visibility: hidden;
}
<table>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
</tr>
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
<tr>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
</tr>
<tr>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
</tr>
<tr>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
</tr>
<tr>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
</tr>
<tr>
<td>31</td>
<td>32</td>
<td>33</td>
<td>34</td>
<td>35</td>
</tr>
</table>
Related
I have a small problem with my table. I am creating a webshop with shopify and there you can write your own html code for your table.
Basically the problem is, that the table doesn't fill out the entire site. It does on mobile version because I used padding and thats necessary beause otherwise there the table shrinks to much. I just need everything staying the same but the table should fill out the whole space of the site when there is more. I tried this using flex grow 1 but it didn't work.
What it look's like if i set width to 100% and without flexbox:
desktop
mobile
What it looks like with flexbox:
mobile flexbox
desktop flexbox
I need another way to adjust the table object to full width without grow but it should have a minimum width because otherwise on mobile version the table looks shitty. Is there a way to grow the table lagerger when the space is given even with a set minimum padding so the table cant shrink under that on mobile.
Here is the code of my table:
<style type="text/css">
<!-- table.sizingchart {
display: flex;
text-align: center;
border-collapse: collapse;
white-space: nowrap;
overflow-x: auto;
}
table.sizingchart td,
table.sizingchart tr {
padding: 5px 15px;
flex-grow: 1;
}
table.sizingchart tr:nth-child(even) {
background: #EEEEEE;
}
-->
</style>
<table class="sizingchart">
<tbody>
<tr>
<td><strong>Length (mm)</strong></td>
<td>44</td>
<td>47</td>
<td>49</td>
<td>52</td>
<td>55</td>
<td>57</td>
<td>60</td>
<td>62</td>
<td>65</td>
<td>67</td>
<td>70</td>
</tr>
<tr>
<td><strong>US Size</strong></td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td><strong>UK & AUS Size</strong></td>
<td>F</td>
<td>H</td>
<td>J</td>
<td>L</td>
<td>N</td>
<td>P</td>
<td>R</td>
<td>T</td>
<td>V</td>
<td>X</td>
<td>Z1</td>
</tr>
<tr>
<td><strong>EUR Size</strong></td>
<td>44</td>
<td>47</td>
<td>49</td>
<td>52</td>
<td>55</td>
<td>57</td>
<td>60</td>
<td>62</td>
<td>65</td>
<td>67</td>
<td>70</td>
</tr>
<tr>
<td><strong>East Asia Size</strong></td>
<td>4</td>
<td>7</td>
<td>9</td>
<td>11</td>
<td>14</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>23</td>
<td>25</td>
<td>27</td>
</tr>
</tbody>
</table>
Thanks already for the help and best regards.
Noah
display: flex will not help you here. Also flex-grow: 1 for <tr> and <td> won't help you as they are not direct children to the .sizingchart class as <tbody> is.
Easiest solution is to remove flexbox and simply add: .sizingchart { width: 100%; }
.sizingchart {
text-align: center;
border-collapse: collapse;
white-space: nowrap;
overflow-x: auto;
width: 100%;
}
table.sizingchart td,
table.sizingchart tr {
padding: 5px 15px;
}
table.sizingchart tr:nth-child(even) {
background: #EEEEEE;
}
<table class="sizingchart">
<tbody>
<tr>
<td><strong>Length (mm)</strong></td>
<td>44</td>
<td>47</td>
<td>49</td>
<td>52</td>
<td>55</td>
<td>57</td>
<td>60</td>
<td>62</td>
<td>65</td>
<td>67</td>
<td>70</td>
</tr>
<tr>
<td><strong>US Size</strong></td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td><strong>UK & AUS Size</strong></td>
<td>F</td>
<td>H</td>
<td>J</td>
<td>L</td>
<td>N</td>
<td>P</td>
<td>R</td>
<td>T</td>
<td>V</td>
<td>X</td>
<td>Z1</td>
</tr>
<tr>
<td><strong>EUR Size</strong></td>
<td>44</td>
<td>47</td>
<td>49</td>
<td>52</td>
<td>55</td>
<td>57</td>
<td>60</td>
<td>62</td>
<td>65</td>
<td>67</td>
<td>70</td>
</tr>
<tr>
<td><strong>East Asia Size</strong></td>
<td>4</td>
<td>7</td>
<td>9</td>
<td>11</td>
<td>14</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>23</td>
<td>25</td>
<td>27</td>
</tr>
</tbody>
</table>
Just erase display:flex (which BTW also cancels all the typical table behaviour and its semantic meaning) and add width: 100% to the table.
And I would also reduce the side padding of the cells so they can get narrower on smaller screens.
html, body {
margin: 0;
}
table.sizingchart {
text-align: center;
border-collapse: collapse;
white-space: nowrap;
overflow-x: auto;
width: 100%;
}
table.sizingchart td,
table.sizingchart tr {
padding: 5px 5px;
}
table.sizingchart tr:nth-child(even) {
background: #EEEEEE;
}
<table class="sizingchart">
<tbody>
<tr>
<td><strong>Length (mm)</strong></td>
<td>44</td>
<td>47</td>
<td>49</td>
<td>52</td>
<td>55</td>
<td>57</td>
<td>60</td>
<td>62</td>
<td>65</td>
<td>67</td>
<td>70</td>
</tr>
<tr>
<td><strong>US Size</strong></td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td><strong>UK & AUS Size</strong></td>
<td>F</td>
<td>H</td>
<td>J</td>
<td>L</td>
<td>N</td>
<td>P</td>
<td>R</td>
<td>T</td>
<td>V</td>
<td>X</td>
<td>Z1</td>
</tr>
<tr>
<td><strong>EUR Size</strong></td>
<td>44</td>
<td>47</td>
<td>49</td>
<td>52</td>
<td>55</td>
<td>57</td>
<td>60</td>
<td>62</td>
<td>65</td>
<td>67</td>
<td>70</td>
</tr>
<tr>
<td><strong>East Asia Size</strong></td>
<td>4</td>
<td>7</td>
<td>9</td>
<td>11</td>
<td>14</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>23</td>
<td>25</td>
<td>27</td>
</tr>
</tbody>
</table>
Using the flexbox table, this is a cross-browser version. The max-width: 550px; of the table will set the width of the table. You may use pixels or a percentage for the max-width of each <td> column.
.sizingchart,
.sizingchart tr {
display: flex;
width: 100%;
max-width: 550px;
border-collapse: collapse;
text-align: center;
}
.sizingchart {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
.sizingchart tbody,
.sizingchart td {
display: block;
flex: 0 0 100%;
width: 100%;
}
.sizingchart td {
max-width: 6%;
padding: 5px 15px;
box-sizing: border-box;
text-align: inherit;
text-align: -webkit-match-parent;
}
.sizingchart td:first-child {
max-width: 140px;
}
.sizingchart tr:nth-child(even) {
background: #eee;
}
<table class="sizingchart">
<tbody>
<tr>
<td><strong>Length (mm)</strong></td>
<td>44</td>
<td>47</td>
<td>49</td>
<td>52</td>
<td>55</td>
<td>57</td>
<td>60</td>
<td>62</td>
<td>65</td>
<td>67</td>
<td>70</td>
</tr>
<tr>
<td><strong>US Size</strong></td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td><strong>UK & AUS Size</strong></td>
<td>F</td>
<td>H</td>
<td>J</td>
<td>L</td>
<td>N</td>
<td>P</td>
<td>R</td>
<td>T</td>
<td>V</td>
<td>X</td>
<td>Z1</td>
</tr>
<tr>
<td><strong>EUR Size</strong></td>
<td>44</td>
<td>47</td>
<td>49</td>
<td>52</td>
<td>55</td>
<td>57</td>
<td>60</td>
<td>62</td>
<td>65</td>
<td>67</td>
<td>70</td>
</tr>
<tr>
<td><strong>East Asia Size</strong></td>
<td>4</td>
<td>7</td>
<td>9</td>
<td>11</td>
<td>14</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>23</td>
<td>25</td>
<td>27</td>
</tr>
</tbody>
</table>
I am currently working on a class project and I am almost done, however I cannot get my calendar page to work properly. I am supposed to create each calendar month using tables, so no javascript or arrays. The calendar pages also needs to be responsive.
I already made each month as a table and I need to put these tables into 2 columns. The issue is that the columns are uneven and I attached a screenshot below to show my problem. I want January - June on the left side and July-December on the right side. I am confused on how to do this.
Each month is also supposed to have text listing important dates right next them. For example: 1st: New Years and 18:Martin Luther King Day should be next to the January table. When I try to put the text in the html code, I can never get the text to align properly. They were either below the tables or underneath them. I even tried tied putting all the text and calendar tables into one big table with four columns. I liked how it look, however I could not get this to be responsive since the table fell off the page in mobile view.
I would appreciate any help I can get.
CSS
.Calendar, th,td{
color: black;
border: 1px solid navy;
background-color: #add8e6;
border-collapse: collapse;
margin-bottom:1%;
margin-top:1%;
}
.eventDay{
background-color:red;
}
.column{
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;
}
#media screen and (max-width: 480px){
.column{
-moz-column-count: 1;
-webkit-column-count: 1;
column-count: 1;
}
}
<div class="row">
<div class="column">
<table class="Calendar">
<tr>
<th colspan="7">January 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><div class="eventDay">1</td></div>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
</tr>
<tr>
<td>17</td>
<td><div class="eventDay">18</td></div>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
<td><div class="eventDay">29</td></div>
<td>30</td>
</tr>
<tr>
<td>31</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">February 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td>14</td>
<td><div class="eventDay">15</td></div>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
</tr>
<tr>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
</tr>
<tr>
<td>28</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">March 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
</tr>
<tr>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
<td><div class="eventDay">26</td></div>
<td>27</td>
</tr>
<tr>
<td>28</td>
<td>29</td>
<td>30</td>
<td>31</td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">April 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1</td>
<td><div class="eventDay">2</td></div>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
<tr>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
</tr>
<tr>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
</tr>
<tr>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">May 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
</tr>
<tr>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
</tr>
<tr>
<td>23</td>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
<td><div class="eventDay">28</td></div>
<td>29</td>
</tr>
<tr>
<td>30</td>
<td><div class="eventDay">31</td></div>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">June 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td><div class="eventDay">12</td></div>
</tr>
<tr>
<td><div class="eventDay">13</td></div>
<td><div class="eventDay">14</td></div>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
</tr>
<tr>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
<td>26</td>
</tr>
<tr>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</th>
<div class="column">
<table class="Calendar">
<tr>
<th colspan="7">July 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td><div class="eventDay">4</td></div>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td><div class="eventDay">10</td></div>
</tr>
<tr>
<td><div class="eventDay">11</td></div>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
</tr>
<tr>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
</tr>
<tr>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td><div class="eventDay">30</td></div>
<td>31</td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">August 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td><div class="eventDay">7</td></div>
</tr>
<tr>
<td><div class="eventDay">8</td></div>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
</tr>
<tr>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
</tr>
<tr>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
</tr>
<tr>
<td>29</td>
<td>30</td>
<td>31</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">September 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td><div class="eventDay">6</td></div>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
</tr>
<tr>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
</tr>
<tr>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td><div class="eventDay">24</td></div>
<td>25</td>
</tr>
<tr>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">October 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>10</td>
<td><div class="eventDay">11</td></div>
<td><div class="eventDay">12</td></div>
<td><div class="eventDay">13</td></div>
<td><div class="eventDay">14</td></div>
<td><div class="eventDay">15</td></div>
<td><div class="eventDay">16</td></div>
</tr>
<tr>
<td><div class="eventDay">17</td></div>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
</tr>
<tr>
<td>31</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">November 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td><div class="eventDay">11</td></div>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
</tr>
<tr>
<td>21</td>
<td>22</td>
<td>23</td>
<td><div class="eventDay">24</td></div>
<td><div class="eventDay">25</td></div>
<td><div class="eventDay">26</td></div>
<td>27</td>
</tr>
<tr>
<td>28</td>
<td><div class="eventDay">29</td></div>
<td>30</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">December 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td><div class="eventDay">1</td></div>
<td><div class="eventDay">2</td></div>
<td><div class="eventDay">3</td></div>
<td><div class="eventDay">4</td></div>
</tr>
<tr>
<td><div class="eventDay">5</td></div>
<td><div class="eventDay">6</td></div>
<td><div class="eventDay">7</td></div>
<td><div class="eventDay">8</td></div>
<td><div class="eventDay">9</td></div>
<td><div class="eventDay">10</td></div>
<td><div class="eventDay">11</td></div>
</tr>
<tr>
<td><div class="eventDay">12</td></div>
<td><div class="eventDay">13</td></div>
<td><div class="eventDay">14</td></div>
<td><div class="eventDay">15</td></div>
<td>16</td>
<td>17</td>
<td>18</td>
</tr>
<tr>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td><div class="eventDay">25</td></div>
</tr>
<tr>
<td><div class="eventDay">26</td></div>
<td><div class="eventDay">27</td></div>
<td><div class="eventDay">28</td></div>
<td><div class="eventDay">29</td></div>
<td><div class="eventDay">30</td></div>
<td><div class="eventDay">31</td></div>
<td></td>
</tr>
</table>
</th>
</div>
</div>
screenshot of calendar tables
This should solve your problem
.Calendar, th,td{
color: black;
border: 1px solid navy;
background-color: #add8e6;
border-collapse: collapse;
margin-bottom:1%;
margin-top:1%;
}
.div_left, div_right {
display: flex;
flex-flow: column;
}
.row_main {display: flex; justify-content: space-around;}
.eventDay{
background-color:red;
}
.column{
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;
display: flex;
}
#media screen and (max-width: 480px){
.column{
-moz-column-count: 1;
-webkit-column-count: 1;
column-count: 1;
}
.row_main { flex-flow:column;}
}
<div class="row_main">
<div class="column">
<div class="div_left">
<table class="Calendar">
<tr>
<th colspan="7">January 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><div class="eventDay">1</td></div>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
</tr>
<tr>
<td>17</td>
<td><div class="eventDay">18</td></div>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
<td><div class="eventDay">29</td></div>
<td>30</td>
</tr>
<tr>
<td>31</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">February 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td>14</td>
<td><div class="eventDay">15</td></div>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
</tr>
<tr>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
</tr>
<tr>
<td>28</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">March 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
</tr>
<tr>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
<td><div class="eventDay">26</td></div>
<td>27</td>
</tr>
<tr>
<td>28</td>
<td>29</td>
<td>30</td>
<td>31</td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">April 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1</td>
<td><div class="eventDay">2</td></div>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
<tr>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
</tr>
<tr>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
</tr>
<tr>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">May 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
</tr>
<tr>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
</tr>
<tr>
<td>23</td>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
<td><div class="eventDay">28</td></div>
<td>29</td>
</tr>
<tr>
<td>30</td>
<td><div class="eventDay">31</td></div>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">June 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td><div class="eventDay">12</td></div>
</tr>
<tr>
<td><div class="eventDay">13</td></div>
<td><div class="eventDay">14</td></div>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
</tr>
<tr>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
<td>26</td>
</tr>
<tr>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</th>
</div>
</div>
<div class="column">
<div class="div_right">
<table class="Calendar">
<tr>
<th colspan="7">July 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td><div class="eventDay">4</td></div>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td><div class="eventDay">10</td></div>
</tr>
<tr>
<td><div class="eventDay">11</td></div>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
</tr>
<tr>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
</tr>
<tr>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td><div class="eventDay">30</td></div>
<td>31</td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">August 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td><div class="eventDay">7</td></div>
</tr>
<tr>
<td><div class="eventDay">8</td></div>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
</tr>
<tr>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
</tr>
<tr>
<td>22</td>
<td>23</td>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
</tr>
<tr>
<td>29</td>
<td>30</td>
<td>31</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">September 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td><div class="eventDay">6</td></div>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
</tr>
<tr>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
</tr>
<tr>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td><div class="eventDay">24</td></div>
<td>25</td>
</tr>
<tr>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">October 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>10</td>
<td><div class="eventDay">11</td></div>
<td><div class="eventDay">12</td></div>
<td><div class="eventDay">13</td></div>
<td><div class="eventDay">14</td></div>
<td><div class="eventDay">15</td></div>
<td><div class="eventDay">16</td></div>
</tr>
<tr>
<td><div class="eventDay">17</td></div>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr>
<td>24</td>
<td>25</td>
<td>26</td>
<td>27</td>
<td>28</td>
<td>29</td>
<td>30</td>
</tr>
<tr>
<td>31</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">November 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td><div class="eventDay">11</td></div>
<td>12</td>
<td>13</td>
</tr>
<tr>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
</tr>
<tr>
<td>21</td>
<td>22</td>
<td>23</td>
<td><div class="eventDay">24</td></div>
<td><div class="eventDay">25</td></div>
<td><div class="eventDay">26</td></div>
<td>27</td>
</tr>
<tr>
<td>28</td>
<td><div class="eventDay">29</td></div>
<td>30</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="Calendar">
<tr>
<th colspan="7">December 2021</th>
</tr>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tues</th>
<th>Wed</th>
<th>Thurs</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td><div class="eventDay">1</td></div>
<td><div class="eventDay">2</td></div>
<td><div class="eventDay">3</td></div>
<td><div class="eventDay">4</td></div>
</tr>
<tr>
<td><div class="eventDay">5</td></div>
<td><div class="eventDay">6</td></div>
<td><div class="eventDay">7</td></div>
<td><div class="eventDay">8</td></div>
<td><div class="eventDay">9</td></div>
<td><div class="eventDay">10</td></div>
<td><div class="eventDay">11</td></div>
</tr>
<tr>
<td><div class="eventDay">12</td></div>
<td><div class="eventDay">13</td></div>
<td><div class="eventDay">14</td></div>
<td><div class="eventDay">15</td></div>
<td>16</td>
<td>17</td>
<td>18</td>
</tr>
<tr>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td><div class="eventDay">25</td></div>
</tr>
<tr>
<td><div class="eventDay">26</td></div>
<td><div class="eventDay">27</td></div>
<td><div class="eventDay">28</td></div>
<td><div class="eventDay">29</td></div>
<td><div class="eventDay">30</td></div>
<td><div class="eventDay">31</td></div>
<td></td>
</tr>
</table>
</th>
</div>
</div>
</div>
I am trying to create a linear annual calendar with a legend below. I am doing this with table but I don't know if this the best method!
My major problem is to remove the table borders of some elements using CSS.
How can I remove the all borders from the rows that have hr ? Only one is working.
I need to have a short space between the rows in the legend.
I need to remove the Left, Top and Bottom borders of the elements with class="noborder".
#data {
border-collapse: collapse;
}
th {
border: 1px solid black;
}
td {
width: 1.5rem;
height: 1rem;
padding-left: 1px;
}
#data tr td {
border: 1px solid black;
}
<!-- remove borders from td with hr -->#data tbody>tr:nth-child(1)>td {
border: 0;
}
#data tbody>tr:nth-last-child(3)>td {
border: 0;
}
<!-- no borders -->.noborder {
border-top: 0;
border-bottom: 0;
border-left: 0;
}
<table id="data">
<thead>
<tr>
<th>Month</th>
<th>S</th>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<th>S</th>
<th>S</th>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<th>S</th>
<th>S</th>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<th>S</th>
<th>S</th>
</tr>
</thead>
<tbody>
<!-- Seperator -->
<tr class="hr-sep">
<td colspan="23">
<hr/>
</td>
</tr>
<!-- Month data -->
<tr>
<td>January</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr>
<td>February</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr>
<td>March</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<!-- Seperator -->
<tr class="hr-sep">
<td colspan="23">
<hr/>
</td>
</tr>
<!-- Legend -->
<tr class="legend">
<td class="noborder"></td>
<td>L1</td>
<td colspan="5"></td>
<td colspan="2"></td>
<td colspan="3"></td>
<td>L3</td>
<td colspan="5"></td>
<td colspan="2"></td>
<td class="noborder" colspan="3"></td>
</tr>
<tr class="legend">
<td class="noborder"></td>
<td>L2</td>
<td colspan="5"></td>
<td colspan="2"></td>
<td class="noborder" colspan="3"></td>
<td>L4</td>
<td colspan="5"></td>
<td colspan="2"></td>
<td class="noborder" colspan="3"></td>
</tr>
</tbody>
</table>
Applied whatever changes were made, can you check.
How can I remove the all borders from the rows that have hr ? Only one is working.
.hr-sep > td{
border: 0 !important;
}
I need to have a short space between the rows in the legend.
<tr><td colspan="23" class="noborder"></td></tr>
I need to remove the Left, Top and Bottom borders of the elements with class="noborder".
.noborder {
border-top: 0 !important;
border-bottom: 0 !important;
border-left: 0 !important;
}
#data {
border-collapse: collapse;
}
th {
border: 1px solid black;
}
td {
width: 1.5rem;
height: 1rem;
padding-left: 1px;
}
#data tr td {
border: 1px solid black;
}
.hr-sep > td{
border: 0 !important;
}
#data tbody>tr:nth-last-child(4)>td {
border: 0;
}
.noborder {
border-top: 0 !important;
border-bottom: 0 !important;
border-left: 0 !important;
}
<table id="data">
<thead>
<tr>
<th>Month</th>
<th>S</th>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<th>S</th>
<th>S</th>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<th>S</th>
<th>S</th>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<th>S</th>
<th>S</th>
</tr>
</thead>
<tbody>
<!-- Seperator -->
<tr class="hr-sep">
<td colspan="23">
<hr/>
</td>
</tr>
<!-- Month data -->
<tr>
<td>January</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr>
<td>February</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr>
<td>March</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<!-- Seperator -->
<tr class="hr-sep">
<td colspan="23">
<hr/>
</td>
</tr>
<!-- Legend -->
<tr class="legend">
<td class="noborder"></td>
<td>L1</td>
<td colspan="5"></td>
<td colspan="2"></td>
<td colspan="3"></td>
<td>L3</td>
<td colspan="5"></td>
<td colspan="2"></td>
<td class="noborder" colspan="3"></td>
</tr>
<tr><td colspan="23" class="noborder"></td></tr>
<tr class="legend">
<td class="noborder"></td>
<td>L2</td>
<td colspan="5"></td>
<td colspan="2"></td>
<td class="noborder" colspan="3"></td>
<td>L4</td>
<td colspan="5"></td>
<td colspan="2"></td>
<td class="noborder" colspan="3"></td>
</tr>
</tbody>
</table>
I am writing a PHP script that is dynamically creating a HTML table.
There are two things that are missing and cannot find info on.
I'd like to reduce the "padding" of the rowspan cell, it is much too large horizontally. What can you use to modify the spacing between the string inside and the end of the cell?
I would also like to start the rowspan from the 3 row up to the last one, and start the colspan from column 3 up to the last one. Can this be done?
HTML source code if you wish to see what the table looks like:
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
}
<table style="width:50%">
<tr>
<th colspan="17">Weight, in Kg</th>
</tr>
<tr>
<th rowspan="11">Height, in cm</th>
</tr>
<tr>
<th></th>
<th>40</th>
<th>45</th>
<th>50</th>
<th>55</th>
<th>60</th>
<th>65</th>
<th>70</th>
<th>75</th>
<th>80</th>
<th>85</th>
<th>90</th>
<th>95</th>
<th>100</th>
<th>105</th>
<th>110</th>
</tr>
<tr>
<th>160</th>
<td>15</td>
<td>17</td>
<td>19</td>
<td>21</td>
<td>23</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>33</td>
<td>35</td>
<td>37</td>
<td>39</td>
<td>41</td>
<td>42</td>
</tr>
<tr>
<th>165</th>
<td>14</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>22</td>
<td>23</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>33</td>
<td>34</td>
<td>36</td>
<td>38</td>
<td>40</td>
</tr>
<tr>
<th>170</th>
<td>13</td>
<td>15</td>
<td>17</td>
<td>19</td>
<td>20</td>
<td>22</td>
<td>24</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>32</td>
<td>34</td>
<td>36</td>
<td>38</td>
</tr>
<tr>
<th>175</th>
<td>13</td>
<td>14</td>
<td>16</td>
<td>17</td>
<td>19</td>
<td>21</td>
<td>22</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>32</td>
<td>34</td>
<td>35</td>
</tr>
<tr>
<th>180</th>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
<td>32</td>
<td>33</td>
</tr>
<tr>
<th>185</th>
<td>11</td>
<td>13</td>
<td>14</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
<td>32</td>
</tr>
<tr>
<th>190</th>
<td>11</td>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
</tr>
<tr>
<th>195</th>
<td>10</td>
<td>11</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>28</td>
</tr>
<tr>
<th>200</th>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>25</td>
<td>26</td>
<td>27</td>
</tr>
</table>
Create a 2x2 "filler" cell. Then start the column label cell one <tr> later. You basically have two header rows running horizontally, hence starting the vertical header row in the third <tr>.
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
}
<table style="width:50%">
<tr>
<th colspan="2" rowspan="2"></th>
<th colspan="17">Weight, in Kg</th>
</tr>
<tr>
<th>40</th>
<th>45</th>
<th>50</th>
<th>55</th>
<th>60</th>
<th>65</th>
<th>70</th>
<th>75</th>
<th>80</th>
<th>85</th>
<th>90</th>
<th>95</th>
<th>100</th>
<th>105</th>
<th>110</th>
</tr>
<tr>
<th rowspan="11">Height, in cm</th>
<th>160</th>
<td>15</td>
<td>17</td>
<td>19</td>
<td>21</td>
<td>23</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>33</td>
<td>35</td>
<td>37</td>
<td>39</td>
<td>41</td>
<td>42</td>
</tr>
<tr>
<th>165</th>
<td>14</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>22</td>
<td>23</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>33</td>
<td>34</td>
<td>36</td>
<td>38</td>
<td>40</td>
</tr>
<tr>
<th>170</th>
<td>13</td>
<td>15</td>
<td>17</td>
<td>19</td>
<td>20</td>
<td>22</td>
<td>24</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>32</td>
<td>34</td>
<td>36</td>
<td>38</td>
</tr>
<tr>
<th>175</th>
<td>13</td>
<td>14</td>
<td>16</td>
<td>17</td>
<td>19</td>
<td>21</td>
<td>22</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>32</td>
<td>34</td>
<td>35</td>
</tr>
<tr>
<th>180</th>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
<td>32</td>
<td>33</td>
</tr>
<tr>
<th>185</th>
<td>11</td>
<td>13</td>
<td>14</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
<td>32</td>
</tr>
<tr>
<th>190</th>
<td>11</td>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
</tr>
<tr>
<th>195</th>
<td>10</td>
<td>11</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>28</td>
</tr>
<tr>
<th>200</th>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>25</td>
<td>26</td>
<td>27</td>
</tr>
</table>
When you say "padding" I'm understanding it as the white space on either side of Wight, in Kg to the border of the cell. If that's the case:
Increase the font size, which might look ugly.
Increase letter spacing, letter-spacing: 0.25em;, which might look ugly.
If you're talking about the white space after the numbers in the 100, 105 and 110 columns you can do above but I'd suggest having all the columns be the same width and then centering all the numbers to even everything out.
Note that there's less white space for triple digits than double digits with this approach.
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
}
th,
td {
min-width: 1.85rem;
}
<table style="width:50%">
<tr>
<th colspan="2" rowspan="2"></th>
<th colspan="17">Weight, in Kg</th>
</tr>
<tr>
<th>40</th>
<th>45</th>
<th>50</th>
<th>55</th>
<th>60</th>
<th>65</th>
<th>70</th>
<th>75</th>
<th>80</th>
<th>85</th>
<th>90</th>
<th>95</th>
<th>100</th>
<th>105</th>
<th>110</th>
</tr>
<tr>
<th rowspan="11">Height, in cm</th>
<th>160</th>
<td>15</td>
<td>17</td>
<td>19</td>
<td>21</td>
<td>23</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>33</td>
<td>35</td>
<td>37</td>
<td>39</td>
<td>41</td>
<td>42</td>
</tr>
<tr>
<th>165</th>
<td>14</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>22</td>
<td>23</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>33</td>
<td>34</td>
<td>36</td>
<td>38</td>
<td>40</td>
</tr>
<tr>
<th>170</th>
<td>13</td>
<td>15</td>
<td>17</td>
<td>19</td>
<td>20</td>
<td>22</td>
<td>24</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>32</td>
<td>34</td>
<td>36</td>
<td>38</td>
</tr>
<tr>
<th>175</th>
<td>13</td>
<td>14</td>
<td>16</td>
<td>17</td>
<td>19</td>
<td>21</td>
<td>22</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>32</td>
<td>34</td>
<td>35</td>
</tr>
<tr>
<th>180</th>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
<td>32</td>
<td>33</td>
</tr>
<tr>
<th>185</th>
<td>11</td>
<td>13</td>
<td>14</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
<td>32</td>
</tr>
<tr>
<th>190</th>
<td>11</td>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
</tr>
<tr>
<th>195</th>
<td>10</td>
<td>11</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>28</td>
</tr>
<tr>
<th>200</th>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>25</td>
<td>26</td>
<td>27</td>
</tr>
</table>
Or you could set a specific amount of padding on columns and center. I personally like the result of the code snippet above. Here you get consistent white space around then numbers while sacrificing equal column width.
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
}
th,
td {
padding: 0.125rem 0.25rem;
}
<table style="width:50%">
<tr>
<th colspan="2" rowspan="2"></th>
<th colspan="17">Weight, in Kg</th>
</tr>
<tr>
<th>40</th>
<th>45</th>
<th>50</th>
<th>55</th>
<th>60</th>
<th>65</th>
<th>70</th>
<th>75</th>
<th>80</th>
<th>85</th>
<th>90</th>
<th>95</th>
<th>100</th>
<th>105</th>
<th>110</th>
</tr>
<tr>
<th rowspan="11">Height, in cm</th>
<th>160</th>
<td>15</td>
<td>17</td>
<td>19</td>
<td>21</td>
<td>23</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>33</td>
<td>35</td>
<td>37</td>
<td>39</td>
<td>41</td>
<td>42</td>
</tr>
<tr>
<th>165</th>
<td>14</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>22</td>
<td>23</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>33</td>
<td>34</td>
<td>36</td>
<td>38</td>
<td>40</td>
</tr>
<tr>
<th>170</th>
<td>13</td>
<td>15</td>
<td>17</td>
<td>19</td>
<td>20</td>
<td>22</td>
<td>24</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>32</td>
<td>34</td>
<td>36</td>
<td>38</td>
</tr>
<tr>
<th>175</th>
<td>13</td>
<td>14</td>
<td>16</td>
<td>17</td>
<td>19</td>
<td>21</td>
<td>22</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>32</td>
<td>34</td>
<td>35</td>
</tr>
<tr>
<th>180</th>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
<td>32</td>
<td>33</td>
</tr>
<tr>
<th>185</th>
<td>11</td>
<td>13</td>
<td>14</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
<td>32</td>
</tr>
<tr>
<th>190</th>
<td>11</td>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>29</td>
<td>30</td>
</tr>
<tr>
<th>195</th>
<td>10</td>
<td>11</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>24</td>
<td>26</td>
<td>27</td>
<td>28</td>
</tr>
<tr>
<th>200</th>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
<td>25</td>
<td>26</td>
<td>27</td>
</tr>
</table>
If neither of those are what you're referencing, please clarify.
Is there a CSS equivalent of frame=void?, or will I have to add frame=void to all the future tables I make?:
<table border=1 rules=all frame=void>
I tried googling it, and I found no results.
The old html presentational attributes are not a useful thing to use nowadays. I would discourage you from using any attributes on any elements in your body with the exceptions of class, id, data-* and things on input, audio, video or img.
To get the same effect, use
table {
border-collapse: collapse;
border-style:hidden;
}
table td {
border-width: 1px;
border-style: inset;
border-color:black;
}
As demoed here: http://jsfiddle.net/HknDE/35/
Use CSS the border property:
table { border:none; }
CSS rules will trump these old-school presentational HTML attributes. Example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CSS and Tables. Void frame?</title>
<style type="text/css">
table {
border:none;
}
</style>
</head>
<body>
<h2>No Frame Attribute</h2>
<table>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>2</td>
<td>4</td>
<td>6</td>
<td>8</td>
<td>10</td>
<td>12</td>
<td>14</td>
<td>16</td>
<td>18</td>
</tr>
<tr>
<td>3</td>
<td>6</td>
<td>9</td>
<td>12</td>
<td>15</td>
<td>18</td>
<td>21</td>
<td>24</td>
<td>27</td>
</tr>
<tr>
<td>4</td>
<td>8</td>
<td>12</td>
<td>16</td>
<td>20</td>
<td>24</td>
<td>28</td>
<td>32</td>
<td>36</td>
</tr>
<tr>
<td>5</td>
<td>10</td>
<td>15</td>
<td>20</td>
<td>25</td>
<td>30</td>
<td>35</td>
<td>40</td>
<td>45</td>
</tr>
<tr>
<td>6</td>
<td>12</td>
<td>18</td>
<td>24</td>
<td>30</td>
<td>36</td>
<td>42</td>
<td>48</td>
<td>54</td>
</tr>
<tr>
<td>7</td>
<td>14</td>
<td>21</td>
<td>28</td>
<td>35</td>
<td>42</td>
<td>49</td>
<td>56</td>
<td>63</td>
</tr>
<tr>
<td>8</td>
<td>16</td>
<td>24</td>
<td>32</td>
<td>40</td>
<td>48</td>
<td>56</td>
<td>64</td>
<td>72</td>
</tr>
<tr>
<td>9</td>
<td>18</td>
<td>27</td>
<td>36</td>
<td>45</td>
<td>54</td>
<td>63</td>
<td>72</td>
<td>81</td>
</tr>
</tbody>
</table>
<h2>Frame = "box"</h2>
<table frame="box">
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>2</td>
<td>4</td>
<td>6</td>
<td>8</td>
<td>10</td>
<td>12</td>
<td>14</td>
<td>16</td>
<td>18</td>
</tr>
<tr>
<td>3</td>
<td>6</td>
<td>9</td>
<td>12</td>
<td>15</td>
<td>18</td>
<td>21</td>
<td>24</td>
<td>27</td>
</tr>
<tr>
<td>4</td>
<td>8</td>
<td>12</td>
<td>16</td>
<td>20</td>
<td>24</td>
<td>28</td>
<td>32</td>
<td>36</td>
</tr>
<tr>
<td>5</td>
<td>10</td>
<td>15</td>
<td>20</td>
<td>25</td>
<td>30</td>
<td>35</td>
<td>40</td>
<td>45</td>
</tr>
<tr>
<td>6</td>
<td>12</td>
<td>18</td>
<td>24</td>
<td>30</td>
<td>36</td>
<td>42</td>
<td>48</td>
<td>54</td>
</tr>
<tr>
<td>7</td>
<td>14</td>
<td>21</td>
<td>28</td>
<td>35</td>
<td>42</td>
<td>49</td>
<td>56</td>
<td>63</td>
</tr>
<tr>
<td>8</td>
<td>16</td>
<td>24</td>
<td>32</td>
<td>40</td>
<td>48</td>
<td>56</td>
<td>64</td>
<td>72</td>
</tr>
<tr>
<td>9</td>
<td>18</td>
<td>27</td>
<td>36</td>
<td>45</td>
<td>54</td>
<td>63</td>
<td>72</td>
<td>81</td>
</tr>
</tbody>
</table>
<h2>Frame = "void"</h2>
<table frame="void">
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>2</td>
<td>4</td>
<td>6</td>
<td>8</td>
<td>10</td>
<td>12</td>
<td>14</td>
<td>16</td>
<td>18</td>
</tr>
<tr>
<td>3</td>
<td>6</td>
<td>9</td>
<td>12</td>
<td>15</td>
<td>18</td>
<td>21</td>
<td>24</td>
<td>27</td>
</tr>
<tr>
<td>4</td>
<td>8</td>
<td>12</td>
<td>16</td>
<td>20</td>
<td>24</td>
<td>28</td>
<td>32</td>
<td>36</td>
</tr>
<tr>
<td>5</td>
<td>10</td>
<td>15</td>
<td>20</td>
<td>25</td>
<td>30</td>
<td>35</td>
<td>40</td>
<td>45</td>
</tr>
<tr>
<td>6</td>
<td>12</td>
<td>18</td>
<td>24</td>
<td>30</td>
<td>36</td>
<td>42</td>
<td>48</td>
<td>54</td>
</tr>
<tr>
<td>7</td>
<td>14</td>
<td>21</td>
<td>28</td>
<td>35</td>
<td>42</td>
<td>49</td>
<td>56</td>
<td>63</td>
</tr>
<tr>
<td>8</td>
<td>16</td>
<td>24</td>
<td>32</td>
<td>40</td>
<td>48</td>
<td>56</td>
<td>64</td>
<td>72</td>
</tr>
<tr>
<td>9</td>
<td>18</td>
<td>27</td>
<td>36</td>
<td>45</td>
<td>54</td>
<td>63</td>
<td>72</td>
<td>81</td>
</tr>
</tbody>
</table>
</body>
</html>
... all three tables above render identically even though they have different values for the frame attribute.
Just set the tables border to 0px. If you want to have those inner borders, set those borders on tr and td.
table { border:0px; }
tr { border-bottom:1px; }
tr.last { border-bottom:0px; }
td { border-right:1px; }
td.last { border-right:0px; }
Or sth like that …