So in part one of HTML tables, I dropped code for a basic Html table structure. Today I will be styling that table with CSS.
<table>
<tbody>
<tr>
<th>Disney</th>
<th>Pixar</th>
<th>Paramount</th>
<th>DreamWorks</th>
<th>Nickelodeon</th>
</tr>
<tr>
<td>Frozen</td>
<td>COCO</td>
<td>Transformers</td>
<td>Shrek</td>
<td>Victorious</td>
</tr>
<tr>
<td>Elsa</td>
<td>Miguel</td>
<td>Mirage</td>
<td>Fiona</td>
<td>Victoria</td>
</tr>
</tbody>
</table>
////
*{
margin: 0;
padding: 0;
font-family: arial;
box-sizing: border-box;
}
body{
height: 100vh;
display: grid;
place-items: center;
background: linear-gradient(to right, rgb(58, 28, 113), rgb(215, 109, 119), rgb(255, 175, 123));
background-size: 100% 100%;
background-repeat: no-repeat;
}
table{
width: 600px;
box-shadow: -1px 12px 12px -6px rgba(0,0,0,0.5);
}
table, td, th{
padding: 20px;
border: 1px solid lightgray;
border-collapse: collapse;
text-align: center;
cursor: pointer;
}
td{
font-size: 18px;
}
th{
background-color: #DE591C;
color: white;
}
tr:nth-child(odd){
background-color: #Fed8b1;
}
tr:nth-child(even){
background-color: #ededed;
}
I used a css code reference from a code I found, but changed the colours and my gradient.
Output:
References:
(218) Design row and column in table using HTML and CSS | Making table using HTML and CSS - YouTube
Design row and column in table using HTML and CSS (iframedev.blogspot.com)