How select last row of a rowgroup - html

My table with rowgroups.
How can I show only the inner borders for the rowgroup?
At the moment the table shows no left/right/top border as wanted, but I don't know how I can select the last row of the rowgroup.
Borders that aren't needed:
div {
font-family: Lato, sans-serif;
font-size: 14px;
font-weight: normal;
}
table {
table-layout: fixed;
}
table.dataTable,
table.dataTable th,
table.dataTable td {
box-sizing: border-box ! important;
}
.tg {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
border: none ! important;
border-collapse: collapse;
border-color: #ccc;
border-spacing: 0;
}
.tg td,
th {
border-color: #ccc;
border-style: solid;
border-width: 1px ! important;
color: #333;
padding: 10px 5px;
word-break: normal;
}
.tg tr td:first-child,
th:first-child {
border-left: none ! important;
}
.tg tr td:last-child,
th:last-child {
border-right: none ! important;
}
.tg tr td,
th {
border-right: none ! important;
border-top: none ! important;
}
.tg tr th {
border-bottom: none ! important;
}
.tg thead tr:last-child th {
border-bottom: 1px solid ! important;
}
.tg .header-left {
background-color: #c0c0c0;
border-color: inherit;
font-size: large;
font-weight: bold;
text-align: left;
top: 0;
vertical-align: top;
will-change: transform;
}
.tg .header-center {
background-color: #c0c0c0;
border-color: inherit;
font-size: large;
font-weight: bold;
text-align: center;
top: 0;
vertical-align: top;
will-change: transform;
}
.tg .header-right {
background-color: #c0c0c0;
border-color: inherit;
font-size: large;
font-weight: bold;
text-align: right;
top: 0;
vertical-align: top;
will-change: transform;
}
.tg .cell-left {
border-color: inherit;
text-align: left;
vertical-align: middle;
}
.tg .cell-center {
border-color: inherit;
text-align: center;
vertical-align: middle;
}
.tg .cell-right {
border-color: inherit;
text-align: right;
vertical-align: middle;
}
<div class="container">
<table class="tg wrap stripe" id="tableData">
<thead>
<tr>
<th class="header-left">Name</th>
<th class="header-left">Position</th>
<th class="header-center">Age</th>
<th class="header-center">Start date</th>
<th class="header-right">Salary</th>
<th class="header-">Office</th>
</tr>
</thead>
<tbody>
<tr>
<td class="cell-left">Airi Satou</td>
<td class="cell-left">Accountant</td>
<td class="cell-center">33</td>
<td class="cell-center">28-Nov-2008</td>
<td class="cell-right">$162,700</td>
<td>Tokyo</td>
</tr>
<tr>
<td class="cell-left">Angelica Ramos</td>
<td class="cell-left">Chief Executive Officer (CEO)</td>
<td class="cell-center">47</td>
<td class="cell-center">09-Oct-2009</td>
<td class="cell-right">$1,200,000</td>
<td>London</td>
</tr>
</tbody>
</table>
</div>

The following selector is what I would use:
.table tr:last-child th,
.table tr:last-child td{
border-bottom: none;
}

This is much easier to get the first row after row group:
table tr.dtrg-group + tr td {
border-top: none ! important;
}

The following CSS rule should remove your unwanted border:
tr:last-child td {
border-bottom: none;
}
Below is a refactored version of your CSS. Less is ALWAYS more, don't set properties to their default values, i.e. font-weight: normal is useless because font weight is already normal, just remove it, unclutter your CSS. Don't border-color: inherit if you're not drawing a border etc.
.container {
font-family: Lato, sans-serif;
font-size: 0.875rem;
}
.tg {
all: unset;
table-layout: fixed;
border-collapse: collapse;
border-color: #ccc;
border-spacing: 0;
}
td,
th {
border-left: 1px solid #ccc;
color: #333;
padding: 0.5em 0.2em;
}
td {
border-bottom: 1px solid #ccc;
}
th {
background-color: #c0c0c0;
font-size: large;
font-weight: bold;
}
.header-left,
.cell-left {
text-align: left;
}
.header-center,
.cell-center {
text-align: center;
}
.header-right,
.cell-right {
text-align: right;
}
td:first-child,
th:first-child {
border-left: none;
}
tr:last-child td {
border-bottom: none;
}
<div class="container">
<table class="tg wrap stripe" id="tableData">
<thead>
<tr>
<th class="header-left">Name</th>
<th class="header-left">Position</th>
<th class="header-center">Age</th>
<th class="header-center">Start date</th>
<th class="header-right">Salary</th>
<th class="header-">Office</th>
</tr>
</thead>
<tbody>
<tr>
<td class="cell-left">Airi Satou</td>
<td class="cell-left">Accountant</td>
<td class="cell-center">33</td>
<td class="cell-center">28-Nov-2008</td>
<td class="cell-right">$162,700</td>
<td>Tokyo</td>
</tr>
<tr>
<td class="cell-left">Angelica Ramos</td>
<td class="cell-left">Chief Executive Officer (CEO)</td>
<td class="cell-center">47</td>
<td class="cell-center">09-Oct-2009</td>
<td class="cell-right">$1,200,000</td>
<td>London</td>
</tr>
</tbody>
</table>
</div>

Related

Why can't I set the height of my table data rows, but can set the height of my table headers?

I've tried all the solutions I can find but the closest I can get to a uniform row height is editing the height of my table headers, the table data rows won't change their height, no matter what I change.
My HTML:
<div class="fields">
<table>
<tr>
<th>Year</th>
<th id="clickable" onclick="openPopup('f2')">Yield/Year</th>
<th id="clickable" onclick="openPopup('f3')">Yield/Year*3</th>
<th id="clickable" onclick="openPopup('f4')">Yield/Year*3*4</th>
</tr>
<tr>
<td>1</td>
<td>387.58</td>
<td>1162.74</td>
<td>4650.96</td>
</tr>
</table>
</div>
My CSS:
.fields table {
width: auto;
table-layout: fixed;
border-collapse: collapse;
white-space: nowrap;
}
.fields td {
font-family: Arial, sans-serif;
color: #213B54;
font-size: 16px;
border-right: 2px solid #213B54;
border-bottom: 2px solid #213B54;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
}
.fields th {
font-family: Arial, sans-serif;
font-size: 16px;
border-right: 2px solid #213B54;
border-bottom: 2px solid #213B54;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 2px;
padding-right: 2px;
text-align: center;
background-color: #9bdcdf;
color: #067A9F;
overflow: hidden;
text-overflow: ellipsis;
width: 75px;
height: 10px;
}
All you should have to do is write a style that targets tr, optionally with classes to differentiate between your header and data rows.
EDIT: By the way, I just noticed that you have the same ID on multiple elements. IDs should uniquely identify a single element. To apply styles to multiple elements, you should use classes.
table {
width: auto;
table-layout: fixed;
border-collapse: collapse;
white-space: nowrap;
}
td {
font-family: Arial, sans-serif;
color: #213B54;
font-size: 16px;
border-right: 2px solid #213B54;
border-bottom: 2px solid #213B54;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
}
th {
font-family: Arial, sans-serif;
font-size: 16px;
border-right: 2px solid #213B54;
border-bottom: 2px solid #213B54;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 2px;
padding-right: 2px;
text-align: center;
background-color: #9bdcdf;
color: #067A9F;
overflow: hidden;
text-overflow: ellipsis;
width: 75px;
height: 10px;
}
tr.table-header {
height: 50px;
}
tr.table-data {
height: 100px;
}
<table>
<tr class="table-header">
<th>Year</th>
<th id="clickable" onclick="openPopup('f2')">Yield/Year</th>
<th id="clickable" onclick="openPopup('f3')">Yield/Year*3</th>
<th id="clickable" onclick="openPopup('f4')">Yield/Year*3*4</th>
</tr>
<tr class="table-data">
<td>1</td>
<td>387.58</td>
<td>1162.74</td>
<td>4650.96</td>
</tr>
</table>

Responsive tables, works on desktop but not exactly the same on mobile

I was trying out this demo to help optimize some tables on a site I'm developing.
Demo works great on my desktop when I resize with a responsive tester extension for chrome:
When loading on my phone it displays everything inline and if more data is added it just spills out:
Anyone have any idea?
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<style>
body {
font-family: "Open Sans", sans-serif;
line-height: 1.25;
}
table {
border: 1px solid #ccc;
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;
}
table caption {
font-size: 1.5em;
margin: .5em 0 .75em;
}
table tr {
background-color: #f8f8f8;
border: 1px solid #ddd;
padding: .35em;
}
table th,
table td {
padding: .625em;
text-align: center;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
#media screen and (max-width: 600px) {
table {
border: 0;
}
table caption {
font-size: 1.3em;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
border-bottom: 3px solid #ddd;
display: block;
margin-bottom: .625em;
}
table td {
border-bottom: 1px solid #ddd;
display: block;
font-size: .8em;
text-align: right;
}
table td::before {
/*
* aria-label has no advantage, it won't be read inside a table
content: attr(aria-label);
*/
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
border-bottom: 0;
}
}
</style>
</head>
<body>
<table>
<caption>Statement Summary</caption>
<thead>
<tr>
<th scope="col">Account</th>
<th scope="col">Due Date</th>
<th scope="col">Amount</th>
<th scope="col">Period</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Account">Visa - 3412</td>
<td data-label="Due Date">04/01/2016</td>
<td data-label="Amount">$1,190</td>
<td data-label="Period">03/01/2016 - 03/31/2016</td>
</tr>
<tr>
<td scope="row" data-label="Account">Visa - 6076</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Amount">$2,443</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
</tr>
<tr>
<td scope="row" data-label="Account">Corporate AMEX</td>
<td data-label="Due Date">03/01/2016</td>
<td data-label="Amount">$1,181</td>
<td data-label="Period">02/01/2016 - 02/29/2016</td>
</tr>
<tr>
<td scope="row" data-label="Acount">Visa - 3412</td>
<td data-label="Due Date">02/01/2016</td>
<td data-label="Amount">$842</td>
<td data-label="Period">01/01/2016 - 01/31/2016</td>
</tr>
</tbody>
</table>
</body>
Could you please check how https://codepen.io/panchroma/pen/YzGEJPd looks for you?
The only changes I made were adding the doctype and upping the #media breakpoint to 950px
Good luck!
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<style>
body {
font-family: "Open Sans", sans-serif;
line-height: 1.25;
}
table {
border: 1px solid #ccc;
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;
}
table caption {
font-size: 1.5em;
margin: .5em 0 .75em;
}
table tr {
background-color: #f8f8f8;
border: 1px solid #ddd;
padding: .35em;
}
table th,
table td {
padding: .625em;
text-align: center;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
#media screen and (max-width: 950px) {
table {
border: 0;
}
table caption {
font-size: 1.3em;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
border-bottom: 3px solid #ddd;
display: block;
margin-bottom: .625em;
}
table td {
border-bottom: 1px solid #ddd;
display: block;
font-size: .8em;
text-align: right;
}
table td::before {
/*
* aria-label has no advantage, it won't be read inside a table
content: attr(aria-label);
*/
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
border-bottom: 0;
}
}
</style>
</head>

How to make HTML Table Take Full Width Using SASS/CSS

I'm trying to style a table using only SASS/CSS. I've set the width of my table to be 100%. However, when I set the font-size of the th element to 0.8em, My table fails to take all of the width it's allowed (Notice that the columns do not reach the border line on the right). How can I fix this using CSS, given that I don't control the HTML?
SASS/CSS
table {
color: black;
background-color: white;
border-color: black;
border-style: solid;
border-width: 0 1px 1px 1px;
border-radius: 5px;
border-collapse: collapse;
border-spacing: 0;
display: block;
overflow: auto;
width: 100%;
thead {
th {
color: white;
background-color: black;
font-weight: bold;
font-size: 0.8em;
padding: 5px 10px;
vertical-align: bottom;
}
th:first-child {
border-top-left-radius: 5px;
}
th:last-child {
border-top-right-radius: 5px;
}
}
tbody {
td {
border-top: 1px solid gray;
padding: 5px 10px;
vertical-align: top;
}
tr:nth-child(2n) {
background-color: lightgray;
}
}
}
<table>
<thead>
<tr>
<th>Method</th>
<th>Runtime</th>
<th align="right">Mean</th>
<th align="right">Ratio</th>
<th align="right">Gen 0/1k Op</th>
<th align="right">Allocated Memory/Op</th>
</tr>
</thead>
<tbody>
<tr>
<td>Baseline</td>
<td>Clr</td>
<td align="right">1.833 us</td>
<td align="right">1.00</td>
<td align="right">2.0542</td>
<td align="right">6.31 KB</td>
</tr>
</tbody>
</table>
Here is what I think you want, I just removed border-collapse, display:block (this make the table default CSS), here is a codepen with SCSS and a working snippet is here too:
table {
color: black;
background-color: white;
border-color: black;
border-style: solid;
border-width: 0 1px 1px 1px;
border-radius: 5px;
border-collapse: separte;
border-spacing: 0;
display: table;
overflow: auto;
width: 100%;
}
table thead th {
color: white;
background-color: black;
font-weight: bold;
font-size: 0.8em;
padding: 5px 10px;
vertical-align: bottom;
}
table thead th:first-child {
border-top-left-radius: 5px;
}
table thead th:last-child {
border-top-right-radius: 5px;
}
table tbody td {
border-top: 1px solid gray;
padding: 5px 10px;
vertical-align: top;
}
table tbody tr:nth-child(2n) {
background-color: lightgray;
}
<table>
<thead>
<tr>
<th>Method</th>
<th>Runtime</th>
<th align="right">Mean</th>
<th align="right">Ratio</th>
<th align="right">Gen 0/1k Op</th>
<th align="right">Allocated Memory/Op</th>
</tr>
</thead>
<tbody>
<tr>
<td>Baseline</td>
<td>Clr</td>
<td align="right">1.833 us</td>
<td align="right">1.00</td>
<td align="right">2.0542</td>
<td align="right">6.31 KB</td>
</tr>
</tbody>
</table>
remove display:block from table
#container,tr{
width:100%;
}
html,body{
width:100%;
}
#container{
border-radius:15px;
background-color:black;
}
table {
color: black;
background-color: white;
border-color: black;
border-style: solid;
border-width: 0 1px 1px 1px;
border-radius: 5px;
border-collapse: collapse;
border-spacing: 0;
overflow: auto;
width: 98%;
margin:0 auto;
}
th {
color: white;
background-color: black;
font-weight: bold;
font-size: 0.8em;
padding: 5px 10px;
vertical-align: bottom;
}
th:first-child {
border-top-left-radius: 5px;
}
th:last-child {
border-top-right-radius: 5px;
}
td {
border-top: 1px solid gray;
padding: 5px 10px;
vertical-align: top;
}
tr:nth-child(2n) {
background-color: lightgray;
}
<html>
<body>
<div id='container'>
<table>
<thead>
<tr>
<th>Method</th>
<th>Runtime</th>
<th align="right">Mean</th>
<th align="right">Ratio</th>
<th align="right">Gen 0/1k Op</th>
<th align="right">Allocated Memory/Op</th>
</tr>
</thead>
<tbody>
<tr>
<td>Baseline</td>
<td>Clr</td>
<td align="right">1.833 us</td>
<td align="right">1.00</td>
<td align="right">2.0542</td>
<td align="right">6.31 KB</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

CSS Corner radius not rendering correctly on Firefox Mac

I have a table with this CSS
.tabelaTripla {
border: 0px;
table-layout: fixed;
width: 100%;
border-collapse: separate;
border-spacing: 20px;
font-size: 0.7em;
line-height: 1.3em;
}
.tabelaTripla tr {
padding: 40px;
margin: 40px;
}
.tabelaTripla th, td{
border: 0px;
width: 33%;
}
.tabelaTripla td{
border: 0px;
width: 33%;
text-align: center;
vertical-align:middle;
word-wrap: break-word;
padding: 40px;
border: 1px solid #AAAAAA;
border-radius: 20px;
}
this works correctly on all browsers but I see this on Firefox for Mac.
Firefox is not rounding the coloring of the columns.
My HTML code for this is simple:
<table class="tabelaTripla">
<tr>
<td>AAA</td>
<td>BBB</td>
<td>CCC</td>
</tr>
</table>
just a table with 3 columns
Still quite not sure where you went wrong, because you haven't provided the CSS for the colours, but you can just set .tabelaTripla to background-color: yellow; and then set the .tabelaTripla td to background-color: white;. (Obviously you can change these colours to whatever you want)
.tabelaTripla {
border: 0px;
table-layout: fixed;
width: 100%;
border-collapse: separate;
border-spacing: 20px;
font-size: 0.7em;
line-height: 1.3em;
background-color: yellow;
}
.tabelaTripla tr {
padding: 40px;
margin: 40px;
}
.tabelaTripla th, td {
border: 0px;
width: 33%;
}
.tabelaTripla td {
border: 0px;
width: 33%;
text-align: center;
vertical-align: middle;
word-wrap: break-word;
padding: 40px;
border: 1px solid #AAAAAA;
border-radius: 20px;
background-color: white;
}
<table class="tabelaTripla">
<tr>
<td>AAA</td>
<td>BBB</td>
<td>CCC</td>
</tr>
</table>
The above snippet will produce this effect:
Edit: By the way, I am also using FireFox on Mac OSX so this should work for you as well.

Unable to apply hover state to HTML table

That's my CSS for styling up the HTML table. I guess something is messing the hover state.
.tg {
border-collapse:collapse;
border-spacing:0;
border-color:#ccc;
}
.tg td {
font-family: Arial, sans-serif;
font-size: 14px;
width: 150px;
height: 10px;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
border-color: #ccc;
color: #333;
background-color: #fff;
}
tr:hover {
background-color:red !important;
}
Since I don't get the desired effect of having a red background while hovering the line. Here's the HTML:
<table class="tg">
<tr class='tr-031e'>
<th class="tg-031e"><b>№</b></th>
<th class="tg-031e"><b>Name</b></th>
<th class="tg-031e"><b>Age</b></th>
</tr>
<tr class='tr-031e'>
<td class="tg-031e"><input type='checkbox' name='person'></td>
<td class="tg-031e">Guy</td>
<td class="tg-031e">18</td>
</tr>
</table>
What about this,
tr:hover td { background-color:red; }
<td>s exist on a layer on top of the <tr>, as a result, your background-color: white is covering up the red.
.tg {
border-collapse:collapse;
border-spacing:0;
border-color:#ccc;
}
.tg td {
font-family: Arial, sans-serif;
font-size: 14px;
width: 150px;
height: 10px;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
border-color: #ccc;
color: #333;
}
tr {
background-color: #fff;
}
tr:hover {
background-color:red !important;
}
Try this:
tr:hover, td:hover {
background-color:red;
}
EDIT
In .tg td, remove:
background-color: #fff;
JSFiddle Demo