I am creating a table and I have used box-sizing: border-box;
property for its parent element body
. I'm getting a vertical red line on the right in Chrome for some screen resolutions (try to zoom in and out to see it). I want to get rid of this red line.
When I remove the box-sizing: border-box;
property from the body
it works fine. But it changes the appearance of other elements. Is there a way to get rid of it.
UPDATE: I want to create a table with the following requirements: 1. Responsive design i.e. horizontal scroll instead of line wrap or overflow. 2. Width 100%. 3. Box-shadow. 4. And it does not distort other element.
Here, is my code:
body {
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
box-sizing: border-box;
color: rgba(0, 0, 0, 0.87);
font: 400 1rem 'Roboto', sans-serif;
margin: 2vh auto;
min-height: 96vh;
padding: 40px;
width: 72vw;
}
table {
background-color: red;
border-collapse: collapse;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
display: block;
overflow-x: auto;
}
tbody {
background-color: blue;
display: table;
width: 100%;
}
tr:not(:first-child):hover {
background-color: #F5F5F5/* [Gray -> 200] */
}
th {
color: #616161;
/* [Gray -> 700] */
font-size: 0.9rem;
padding: 16px;
text-align: left;
}
td {
border-top: 1px solid #E0E0E0;
/* [Gray -> 300] */
padding: 8px 16px;
}
<body>
<table>
<tr>
<th>Name</th>
<th>Field</th>
<th>Class</th>
</tr>
<tr>
<td>Mansoor</td>
<td>Science</td>
<td>XI-B</td>
</tr>
<tr>
<tr>
<td>Manny</td>
<td>Science</td>
<td>XI-B</td>
</tr>
<tr>
<td>Joe</td>
<td>Science</td>
<td>XI-B</td>
</tr>
<tr>
<td>John</td>
<td>Science</td>
<td>XI-C</td>
</tr>
</table>
</body>