I have table indentations controlled by padding. I set class="indent-(number_inches)" to choose indentation level. I am running into an issue where the <th> tags always indent based on the indent-18 class instead of the assigned class.
Whenever I remove the .indent-18 class from my CSS it takes on the properties of .indent-12 class instead.
Replacing th with th:first-child in css does not work
I am also open to any other, non-related critique on my code. I am still learning so teaching me the proper way would help a lot
/* TABLE CLASSES*/
.units {
text-align: left;
}
.table-header {
font-size: 20px;
text-align: center;
border-bottom: 2px solid black;
}
.big-header {
font-size: 16px;
}
.small-header {
font-size: 16px;
}
/*
Nest table based on these values
Indent 0" 6" 12" or 18", based off of excel indentations
*/
.indent-0 td:first-child,
th {
padding: 10px;
padding-left: 10px;
}
.indent-6 td:first-child,
th {
padding: 10px;
padding-left: 3%;
}
.indent-12 td:first-child,
th {
padding: 10px;
padding-left: 6%;
}
.indent-18 td:first-child,
th {
padding: 10px;
padding-left: 9%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<!-- USER FORM STARTS-->
<form action="/update_car_data/" method="post">
<div class="row">
<!-- TABLE 1 -->
<div class="col-md-6 col-sm-12 col-xs-12">
<table>
<thead>
<th class="table-header" colspan="3">Model Inputs, Internal Combustion Engine</th>
</thead>
<!--
Structure of table row:
Title | value | units
-->
<tr class="indent-0">
<td>Vehicle Life</td>
<td><input name="G18_Car" value="{{data['G18_Car']}}"></td>
<td class="units">Years</td>
</tr>
<tr class="indent-0">
<td>Distance Traveled Per Year After Purchase</td>
<td><input name="G19_Car" value="{{data['G19_Car']}}"></td>
<td class="units">Miles</td>
</tr>
<!--Generation, Assembly, and Delivery-->
<th class="big-header indent-0">Manufacture, Assembly, and Delivery</th>
<tr class="indent-6">
<td>Manufacture Assembly - GHG Emissions</td>
<td><input name="G22_Car" value="{{data['G22_Car']}}"></td>
<td class="units">MT CO2e</td>
</tr>
<tr class="indent-6">
<td>Delivery - GHG Emissions</td>
<td><input name="G23_Car" value="{{data['G23_Car']}}"></td>
<td class="units">MT CO2e</td>
</tr>
<!--Operation and Disposal-->
<tr>
<th class="big-header indent-0">Operation and Disposal</th>
</tr>
<!--Tailpipe emissions-->
<tr>
<th class="small-header indent-6">Tailpipe Emissions</th>
</tr>
<tr class="indent-12">
<td>Emissions Per Gallon of Gasoline</td>
<td><input name="G28_Car" value="{{data['G28_Car']}}"></td>
<td class="units">kg CO2e/gal</td>
</tr>
<tr class="indent-12">
<td>Fuel Efficiency</td>
<td><input name="G29_Car" value="{{data['G29_Car']}}"></td>
<td class="units">Miles/gal</td>
</tr>
<!--Fuel Cycle-->
<tr>
<th class="small-header indent-6">Fuel Cycle</th>
</tr>
<tr>
<th class="small-header indent-12">Ethanol Fuel Cycle</th>
</tr>
<tr class="indent-18">
<td>Volume % of Ethanol</td>
<td><input name="G23_Car" value="{{data['G32_Car']}}"></td>
<td class="units">%</td>
</tr>
<tr class="indent-18">
<td>Ethanol Fuel Cycle Basis</td>
<td><input name="G44_Car" value="{{data['G44_Car']}}"></td>
<td class="units">kg CO2e/gal</td>
</tr>
<tr>
<th class="small-header indent-12">Petroleum (Gasoline) Fuel Cycle</th>
</tr>
<tr class="indent-18">
<td>Upstream (Well to Refining Emissions)</td>
<td><input name="G33_Car" value="{{data['G33_Car']}}"></td>
<td class="units">MT CO2e/BBL-crude</td>
</tr>
<!--Refining-->
<tr>
<th class="small-header indent-18">Refining</th>
</tr>
<tr class="indent-18">
<td>Processing (Volumetric) Gain</td>
<td><input name="G36_Car" value="{{data['G36_Car']}}"></td>
<td class="units">%</td>
</tr>
<tr class="indent-18">
<td>Refining GHG Emissions Basis</td>
<td><input name="G37_Car" value="{{data['G37_Car']}}"></td>
<td class="units">MT CO2e/BBL-crude</td>
</tr>
<!--Distrubition (Refining to sales)-->
<tr>
<th class="small-header indent-12">Distrubition (Refining to Sales)</th>
</tr>
<tr class="child-row indent-18">
<td>Evaporative Loss</td>
<td><input name="G40_Car" value="{{data['G40_Car']}}"></td>
<td class="units">%</td>
</tr>
<tr class="indent-18">
<td>Carbon Intensity (GWP 100) of Motor Gasoline</td>
<td><input name="G41_Car" value="{{data['G41_Car']}}"></td>
<td class="units">MT CO2e/MT</td>
</tr>
<tr class="indent-18">
<td>Tank-Truck Shipment to Sales Centers</td>
<td><input name="G42_Car" value="{{data['G42_Car']}}"></td>
<td class="units">MT CO2e/year</td>
</tr>
<tr class="indent-0">
<td>Disposal -GHG Emissions</td>
<td><input name="G46_Car" value="{{data['G46_Car']}}"></td>
<td class="units">MT CO2e</td>
</tr>
</table>
</div>
<!-- TABLE 2 -->
<div class="col-md-6 col-sm-12 col-xs-12">
<table>
<tr>
<th class="table-header" colspan="3">Model Inputs, EV (Electric Vehicle)</th>
</tr>
<tr class="child-row">
<td>Vehicle Life</td>
<td><input name="G18_Car" value="{{data['G18_Car']}}"></td>
<td>Years</td>
</tr>
<tr class="child-row">
<td>Delivery -GHG emissions</td>
<td><input name="G19_Car" value="{{data['G19_Car']}}"></td>
<td>Miles</td>
</tr>
</table>
</div>
<br>
<div class="col-12">
<button name="updateBtn" type="submit">Update</button>
</div>
</div>
</form>
You should change the CSS like this :
.indent-0 td:first-child, th.indent-0 {
padding: 10px;
padding-left: 10px;
}
.indent-6 td:first-child, th.indent-6 {
padding: 10px;
padding-left: 3%;
}
.indent-12 td:first-child, th.indent-12 {
padding: 10px;
padding-left: 6%;
}
.indent-18 td:first-child, th.indent-18 {
padding: 10px;
padding-left: 9%;
}
Fiddle
Related
I want to give a spec table for the Watch 4. For now, I have this code.
<div class="specs">
<ul class="info">
<li>Lengte</li>
<li>44 mm</li>
</ul>
</div>
<div class="specs">
<ul class="info">
<li>Breedte</li>
<li>43.3 mm</li>
</ul>
</div>
with this CSS code
.specs{
position: relative;
top: 20px;
display: flex;
flex-direction: row;
align-items: center;
}
.info{
display: flex;
flex-direction: row;
color: black;
align-items: center;
margin-left: auto;
margin-right: auto;
border-bottom: 1px black solid;
padding: 0;
}
.info li{
display: flex;
flex-direction: row;
margin-right: 200px;
margin-left: 200px;
}
Here is the full project https://jsfiddle.net/2wvfyg16/
You might have to make the CSS tab bigger.
All the way at the bottom at the tab "Verbindungen".
It is all miss aligned.
As the data appears to be tabular, this snippet is a simple start on setting out the two columns with spacing in an HTML table.
Obviously you'll want to change things to give the exact layout your want but it does demonstrate that an HTML table can give the sort of formatting required.
#specs {
width: 100vw;
border-collapse: collapse;
}
#specs th {
font-size: 3em;
text-align: left;
padding-top: 1em;
}
#specs td {
width: 50%;
padding: 1em 5em;
}
#specs td {
font-size: 2em;
}
#specs tr:not(.cat) {
border-bottom: solid 1px black;
padding: 1em;
}
<table id="specs">
<tr class="cat">
<th colspan="2">Formaat</th>
</tr>
<tr>
<td>Lengte</td>
<td>44 mm</td>
<tr>
<td>Breedte</td>
<td>43.3 mm</td>
</tr>
<tr>
<td>Hoogte</td>
<td>9.8 mm</td>
</tr>
<tr>
<td>Gewicht</td>
<td>30 gram</td>
</tr>
<tr>
<td>Stofdicht</td>
<td>Ja</td>
</tr>
<tr>
<td>Spatwaterdicht</td>
<td>Ja</td>
</tr>
<tr>
<td>Waterdicht</td>
<td>Ja</td>
</tr>
<tr class="cat" colspan="2">
<th colspan="2">Display</th>
</tr>
<tr>
<td>Schermgrootte</td>
<td>40 & 44 mm</td>
</tr>
<tr>
<td>Schermtype</td>
<td>OLED</td>
</tr>
<tr class="cat" colspan="2">
<th colspan="2">Processor</th>
</tr>
<tr>
<td>Chipset</td>
<td>Samsung Exynos W920</td>
</tr>
<tr>
<td>Opslagcapaciteit</td>
<td>16 GB</td>
</tr>
<tr>
<td>Werkgeheugen</td>
<td>1500 MB</td>
</tr>
<tr class="cat" colspan="2">
<th colspan="2">Software</th>
</tr>
<tr>
<td>Besturingssysteem</td>
<td>One UI Watch</td>
</tr>
<tr class="cat" colspan="2">
<th colspan="2">Sensoren</th>
</tr>
<tr>
<td>Accelerometer</td>
<td>Jas</td>
</tr>
<tr>
<td>Hartslagmeter</td>
<td>Ja</td>
</tr>
<tr>
<td>Gyroscoop</td>
<td>Ja</td>
</tr>
<tr>
<td>GPS</td>
<td>Ja</td>
</tr>
<tr class="cat" colspan="2">
<th colspan="2">Batterij</th>
</tr>
<tr>
<td>Capaciteit</td>
<td>361 mAh</td>
</tr>
<tr>
<td>Vervangbaar</td>
<td>Nee</td>
</tr>
<tr class="cat" colspan="2">
<th colspan="2">Verbindingen</th>
</tr>
<tr>
<td>WiFi</td>
<td>Ja</td>
</tr>
<tr>
<td>Mobiel Netwerk</td>
<td>Nee</td>
</tr>
<tr>
<td>Bluetooth</td>
<td>Bluetooth 5.0</td>
</tr>
<tr>
<td>NFC</td>
<td>Ja</td>
</tr>
</table>
use justify items center i think it would work for that problem
I want to send mail with the below template from code. I am trying to hide and display the secondary table with the checkbox. I think I am stuck with the css selector. Is it possible to hide and show something with the checkbox. Important thing is I want to do it in only css , " NO JS " Here is the codepen edit link : https://codepen.io/rishisarma/pen/QWqyqXd?editors=1100
.box {
display:none;
}
<-- Here is the issue I think when I tried to hide and display the table it is not working.-->
input[id='trigger']:checked table.box{
display:block;
}
table {
font-family: "Trebuchet MS";
margin: 8px;
}
tr:nth-child(odd) {
background-color: #f7f7f7;
}
.rightalign {
text-align: right;
width: 125px;
}
th {
background-color: #e84f32;
padding: 8px;
color: white;
border: 1px solid #e0e0e0;
}
td {
padding: 8px;
border: 1px solid #e0e0e0;
}
<table>
<thead>
<tr>
<th colspan="9" style="width:100%;" id="head">Client Wise AttendenceReport (2021/12/05)</th>
</tr>
<tr>
<th></th>
<th>SRNO</th>
<th>Customer</th>
<th>Organizations</th>
<th>Attendees (2021/12/04)</th>
<th>Attendees (2021/12/05)</th>
<th>Txns (2021/12/04)</th>
<th>Txns (2021/12/05)</th>
<th>Inclination (%)</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="checkbox" id="trigger">
</td>
<td>1</td>
<td>TSTS</td>
<td>33 (0%)</td>
<td>1605382</td>
<td>1605563 (0.01)</td>
<td>139313</td>
<td>20726</td>
<td>-85.12</td>
</tr>
<tr>
<td colspan="9">
<table class = "box">
<tr>
<td colspan="5" style="background-color: #e84f32; padding: 8px; color:white; text-align:center">Organisation Wise Transaction Report On 05-Dec- 2021</td>
</tr>
<tr>
<th>Slno</th>
<th>Organisation</th>
<th>Registered Users</th>
<th>Present Today</th>
<th>Percent(%)</th>
</tr>
<tr>
<td>1</td>
<td>TSTSATTENDANCE</td>
<td class="rightalign">294</td>
<td class="rightalign">3</td>
<td class="rightalign">1%</td>
</tr>
</table>
</td>
</tr>
<tr>
<td></td>
<td>2</td>
<td>GVK</td>
<td>2 (0%)</td>
<td>1329</td>
<td>1329 (0)</td>
<td>681</td>
<td>686</td>
<td>0.73</td>
</tr>
<tr>
<td></td>
<td>3</td>
<td>SIL</td>
<td>33 (0%)</td>
<td>202240</td>
<td>203042 (0.4)</td>
<td>111348</td>
<td>7519</td>
<td>-93.25</td>
</tr>
</tbody>
</table>
I would like to display a certain table when the user hovers over the row of another table without using any JS. I have seen solutions for similar things but they require your elements to be descendent, child or adjacent elements. I would like the tables to be properly seperated though. Kind of like:
#HS {
display: none;
}
#Uni {
display: none;
}
#HSrow:hover {
background-color: rgba(167, 177, 189);
}
.HSrow:hover+.HS {
display: block;
}
.HSrow:hover+.Uni {
display: block;
}
#Unirow:hover {
background-color: rgba(167, 177, 189);
color: black;
}
body {
color: white;
font-family: din6776;
font-size: var(--fs-body);
line-height: 1.6;
background-image: url(../img/Body_6.png);
background-repeat: repeat-y;
background-size: 100% auto;
background-attachment: fixed;
padding: 0 5vw 10vh 5vw;
}
table {
margin-left: auto;
background-color: rgba(0, 97, 182, 0.7);
}
table,
th,
td {
border: 1px solid #cccccc;
}
th,
td {
padding: 5px;
}
tr:nth-child(even) {
background-color: rgba(140, 140, 140, 0.4);
}
<div class="container">*,
<table id="Edu" style="width:35vw">
<thead>
<tr>
<th>Timespan</th>
<th>Place</th>
<th>Description</th>
</tr>
</thead>
<tr id="HSrow">
<th>09.2010 – 11.2014</th>
<td>HS</td>
<td>Engineering</td>
</tr>
<tr id="Unirow">
<th>10.2012 – 01.2013</th>
<td>University 2</td>
<td>Laboratory</td>
</tr>
</table>
<table id="HS" style="width:35vw">
<thead>
<tr>
<th id="texthead" colspan="6">HS</th>
</tr>
</thead>
<tbody>
<tr>
<td id="Description">Version</td>
<td id="Description" colspan="3">Name</td>
<td id="Description" colspan="3">Date</td>
</tr>
<tr>
<td>V 1.0</td>
<td colspan="3">John Doe</td>
<td colspan="3">12345</td>
</tr>
<tr>
<td id="Description" colspan="3">lalala</td>
<td id="Description" colspan="3">lalala</td>
</tr>
<tr>
<td colspan="3">lalala</td>
<td colspan="3">lalala</td>
</tr>
</tbody>
</table>
<table id="Uni" style="width:35vw">
<thead>
<tr>
<th id="texthead" colspan="6">Uni</th>
</tr>
</thead>
<tbody>
<tr>
<td id="Description">Version</td>
<td id="Description" colspan="3">Name</td>
<td id="Description" colspan="3">Date</td>
</tr>
<tr>
<td>V 1.0</td>
<td colspan="3">John Doe</td>
<td colspan="3">12345</td>
</tr>
<tr>
<td id="Description" colspan="3">lalala</td>
<td id="Description" colspan="3">lalala</td>
</tr>
<tr>
<td colspan="3">lalala</td>
<td colspan="3">lalala</td>
</tr>
</tbody>
</table>
</div>
I would like the table with the id "HS" to pop up when I hover over "HSrow" and the same for the Uni table.
Is it possible without JS?
Best Regards
In case someone finds this later, I have been able to solve this using "onmouseover" and "onmouseout" together with a "makevis" and "makinvis" command:
<tr class="hover" onmouseover="makevis('HStable')" onmouseout="makeinvis('HStable')">
I would like to construct a table as follows:
I am trying to construct same table in html but having trouble. Table header needs to be exact. Any help is helpful
You can use the rowspan attribute:
th {
border:1px solid #000;
height: 20px;
width: 150px;
}
<table>
<thead>
<tr>
<th rowspan="4">#</th>
<th>Name</th>
<th rowspan="2">Permanent Address</th>
<th rowspan="2">Type of Job</th>
<th rowspan="2">Start work</th>
</tr>
<tr>
<th>ID</th>
</tr>
<tr>
<th>M/F</th>
<th rowspan="2">Contract</th>
<th rowspan="2">Place of Work</th>
<th rowspan="2">Work Stops</th>
</tr>
<tr>
<th>Birth</th>
</tr>
</thead>
</table>
FYI: there is also a colspan attribute if you need to span multiple columns.
Try this......
body {
padding: 50px;
}
table {
width: 100%;
border-collapse: collapse;
}
td,
th {
padding: 10px;
border: 1px solid black;
}
<table>
<tbody>
<tr>
<td rowspan="4">#</td>
<td>Name</td>
<td rowspan="2">Permanent Address</td>
<td rowspan="2">Type of Job</td>
<td rowspan="2">Start work</td>
</tr>
<tr>
<td>ID</td>
</tr>
<tr>
<td>M/F</td>
<td rowspan="2">Contract</td>
<td rowspan="2">Place of Work</td>
<td rowspan="2">Work Stops</td>
</tr>
<tr>
<td>Birth</td>
</tr>
</tbody>
</table>
I have a complicated set of table rows with colspans and rowspans all over the shop. All works fine except for the bottom row in Internet Explorer which forces it's height to be the same as the previous row, which is set to rowspan="2". How can I fix this?
Also, the layout needs to be a table because a PDF generator uses it and that requires tables. Ideally the HTML layout wouldn't change at all, but it can change if it needs to.
Below is the code. Look at it in Google Chrome to see how it should be displaying in IE.
.MhrPayslipDetail {
display: block;
font-family: sans-serif;
font-size: 16px;
padding: 20px 60px;
text-align: center;
}
.MhrPayslipDetail-payslip {
background-color: #fff;
border-collapse: separate;
border-spacing: 10px;
width: 100%;
}
.MhrPayslipDetail-label {
background-color: #c1c1c1;
border: 1px solid #c1c1c1;
border-radius: 5px;
font-weight: bold;
padding: 4px;
text-align: left;
vertical-align: middle;
}
.MhrPayslipDetail-cell,
.MhrPayslipDetail-cellRight {
background-color: #fff;
border: 1px solid #c1c1c1;
border-radius: 5px;
padding: 4px;
text-align: left;
vertical-align: middle;
}
.MhrPayslipDetail-cellRight {
text-align: right;
}
.MhrPayslipDetail-list {
border: 0;
border-collapse: collapse;
width: 100%;
}
.MhrPayslipDetail-listCell,
.MhrPayslipDetail-listLabel,
.MhrPayslipDetail-listCellHeader {
border: 0;
padding: 1px;
text-align: left;
vertical-align: middle;
}
.MhrPayslipDetail-listCellRight,
.MhrPayslipDetail-listCellHeaderRight {
border: 0;
padding: 1px;
text-align: right;
vertical-align: middle;
}
.MhrPayslipDetail-listLabel,
.MhrPayslipDetail-listCellHeader {
font-weight: bold;
width: 50%;
}
.MhrPayslipDetail-details {
font-size: .9em;
}
.MhrPayslipDetail-paymentsDetails,
.MhrPayslipDetail-deductionsDetails {
height: 21em;
vertical-align: top;
}
.MhrPayslipDetail-thisPeriodDetails,
.MhrPayslipDetail-yearToDateDetails {
height: 10em;
vertical-align: top;
}
<div class="MhrPayslipDetail">
<table class="MhrPayslipDetail-payslip">
<tbody>
<tr>
<td colspan="3" rowspan="3" class="MhrPayslipDetail-cell MhrPayslipDetail-paymentsDetails">
<table class="MhrPayslipDetail-details MhrPayslipDetail-list">
<thead>
<tr>
<th class="MhrPayslipDetail-listCellHeader">Description</th>
<th class="MhrPayslipDetail-listCellHeaderRight">U/T</th>
<th class="MhrPayslipDetail-listCellHeaderRight">Rate</th>
<th class="MhrPayslipDetail-listCellHeaderRight">Cash</th>
</tr>
</thead>
<tbody>
<tr>
<td class="MhrPayslipDetail-listCell">Test Basic Pay</td>
<td class="MhrPayslipDetail-listCellRight"></td>
<td class="MhrPayslipDetail-listCellRight"></td>
<td class="MhrPayslipDetail-listCellRight">200.00</td>
</tr>
</tbody>
</table>
</td>
<td colspan="2" rowspan="3" class="MhrPayslipDetail-cell MhrPayslipDetail-deductionsDetails">
<table class="MhrPayslipDetail-details MhrPayslipDetail-list">
<thead>
<tr>
<th class="MhrPayslipDetail-listCellHeader">Description</th>
<th class="MhrPayslipDetail-listCellHeaderRight">Cash</th>
</tr>
</thead>
<tbody>
<tr>
<td class="MhrPayslipDetail-listCell">Tax</td>
<td class="MhrPayslipDetail-listCellRight">25.40</td>
</tr>
<tr>
<td class="MhrPayslipDetail-listCell">NI</td>
<td class="MhrPayslipDetail-listCellRight">24.00</td>
</tr>
</tbody>
</table>
</td>
<td colspan="2" class="MhrPayslipDetail-cell MhrPayslipDetail-thisPeriodDetails">
<table class="MhrPayslipDetail-details MhrPayslipDetail-list">
<thead>
<tr>
<th class="MhrPayslipDetail-listCellHeader">Description</th>
<th class="MhrPayslipDetail-listCellHeaderRight">Cash</th>
</tr>
</thead>
<tbody>
<tr>
<td class="MhrPayslipDetail-listCell">Taxable Pay</td>
<td class="MhrPayslipDetail-listCellRight">200.00</td>
</tr>
<tr>
<td class="MhrPayslipDetail-listCell">Employers National Insurance</td>
<td class="MhrPayslipDetail-listCellRight">27.60</td>
</tr>
<tr>
<td class="MhrPayslipDetail-listCell">Niable Pay</td>
<td class="MhrPayslipDetail-listCellRight">200.00</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<th colspan="2" class="MhrPayslipDetail-label">Year-to-date</th>
</tr>
<tr>
<td colspan="2" rowspan="2" class="MhrPayslipDetail-cell MhrPayslipDetail-yearToDateDetails">
<table class="MhrPayslipDetail-details MhrPayslipDetail-list">
<tbody>
<tr>
<td class="MhrPayslipDetail-listCell">Taxable Pay</td>
<td class="MhrPayslipDetail-listCellRight">7,200.00</td>
</tr>
<tr>
<td class="MhrPayslipDetail-listCell">NI</td>
<td class="MhrPayslipDetail-listCellRight">622.08</td>
</tr>
<tr>
<td class="MhrPayslipDetail-listCell">Tax</td>
<td class="MhrPayslipDetail-listCellRight">25.40</td>
</tr>
<tr>
<td class="MhrPayslipDetail-listCell">Niable Pay</td>
<td class="MhrPayslipDetail-listCellRight">7,200.00</td>
</tr>
<tr>
<td class="MhrPayslipDetail-listCell">Employers National Insurance</td>
<td class="MhrPayslipDetail-listCellRight">713.73</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<th class="MhrPayslipDetail-label">Payments</th>
<td class="MhrPayslipDetail-cellRight" colspan="2">200.00</td>
<th class="MhrPayslipDetail-label">Deductions</th>
<td class="MhrPayslipDetail-cellRight">49.40</td>
</tr>
</tbody>
</table>
</div>
UPDATE
Since submitting this question I have tried using sub-tables to separate out the columns, however I found that when I did that I wasn't able to get them to line up correctly due to border spacing and the PDF generator's lack of being able to use border-collapse:collapse;.
As an FYI, this is the PDF generator the system is using.