I have a table compiled with data and am having positioning problems with overlapping rows and styling properties. I have tried tweaking the CSS but nothing really worked.
below is my HTML table
<table class="ui-widget" id="lines">
<tbody>
<tr>
<th>Line Item Number</th>
<th>Line Item Date</th>
<th>Unit Cost</th>
<th>Number of Units</th>
<th>Line Item Total</th>
<th>Task Code</th>
<th>Expense Code</th>
<th>Timekeeper ID</th>
<th>Line Item Description</th>
</tr>
<tr class="errortrue">
<td>1</td>
<td>20150301</td>
<td>1</td>
<td>1</td>
<td>4</td>
<td></td>
<td>E1</td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="9" class="error">
Line : 1 NULL Value is not in the defined list for LINE ITEM TAX TYPE<br/>
Line : 1 MATTER NAME is a required field<br/>
Line : 1 BILLING END DATE is a required field<br/>
Line : 1 INVOICE DATE is a required field<br/>
Line : 1 BILLING START DATE is a required field<br/>
</td>
</tr>
<tr class="errortrue">
<td>2</td>
<td>20150304</td>
<td>2</td>
<td>2</td>
<td>6</td>
<td></td>
<td>E2</td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="9" class="error">
Line : 2 NULL Value is not in the defined list for LINE ITEM TAX TYPE<br/>
</td>
</tr>
<tr class="errortrue">
<td>3</td>
<td>20150306</td>
<td>3</td>
<td>3</td>
<td>12</td>
<td>T3</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="9" class="error">
Line : 3 NULL Value is not in the defined list for LINE ITEM TAX TYPE<br/>
</td>
</tr>
</tbody>
</table>
CSS:
<style>
td error { color: red; font-size: 100%;}
tr.errortrue { color: #c33; font-size: 100%; font-weight: bold;}
table.lines th { background-color : grey; color: white; padding: 5px;}
table {empty-cells: show; border-collapse: collapse; }
table.lines td { text-align: center;}
table.header { float: left; }
table.header th { text-align: left; }
table.header td{ text-align: right; }
table.header td.right{ text-align: left; }
table.header tfoot th { text-align: left; background: #ebebeb}
table.header tfoot td { text-align: right; background: #ebebeb}
td.right, th.right { text-align: right; }
</style>
Here are the snapshots of CSS in Chrome
Invoice Line Items Table CSS
[1]: http://i.imgur.com/cq72QUU.png
tr css
[2]: http://i.imgur.com/jSV6XZJ.png
I am a beginner at CSS. Can someone please help me with this?
Try adding this css
th {
padding:10px;
margin:10px;
}
td {
padding:10px;
margin:10px;
}
Manipulate it the way you want. here is the jfiddle link. Good luck. http://jsfiddle.net/JoshuaHurlburt/avttkdst/2/
Have a look at this Fiddle I noticed you are assigning a class to the id lines in your css when it should be and id. Example you have table.lines th which should really be table#lines th unless you change in your html <table class="ui-widget" id="lines"> to <table class="ui-widget" class="lines">
CSS:
table#lines td.error {
color: red;
font-size: 100%;
text-align:left;
padding-left:15px;
}
th {
margin:5px;
padding:5px;
}
td {
padding:10px;
margin:10px;
}
tr.errortrue {
color: #c33;
font-size: 100%;
font-weight: bold;
}
table#lines th {
background-color : grey;
color: white;
padding: 5px;
}
table {
empty-cells: show;
border-collapse: collapse;
}
table#lines td {
text-align: center;
}
.align-left {
text-align:left;
}
table.header {
float: left;
}
table.header th {
text-align: left;
}
table.header td {
text-align: right;
}
table.header td.right {
text-align: left;
}
table.header tfoot th {
text-align: left;
background: #ebebeb
}
table.header tfoot td {
text-align: right;
background: #ebebeb
}
td.right, th.right {
text-align: right;
}
I applied some changes to this fiddle which may be what you are looking for. Let me know.
Related
My current table data is look like image1 how can make it to become the image2 the data look like card? I tried the border-radius CSS, but it still looks same nothing changes. I think the current data look very messy so I think change to card row data will become better...
table {
border: 1px solid #ccc;
width: 100%;
margin:0;
padding:0;
border-collapse: collapse;
border-spacing: 0;
}
table tr {
border: 2px solid #eee;
border-radius: 25px;
padding: 20px;
}
table th, table td {
padding: 10px;
text-align: center;
}
table th {
text-transform: uppercase;
font-size: 14px;
letter-spacing: 1px;
}
<table v-if="items.length >0">
<thead>
<th>{{$t('date')}}</th>
<th>{{$t('description')}}</th>
<th>{{$t('previousBalance')}}</th>
<th>{{$t('debit')}}</th>
<th>{{$t('credit')}}</th>
<th>{{$t('balance')}}</th>
</thead>
<tbody v-for="(item) in items" :key="item">
<tr>
<td :data-label="$t('date')">{{item.txDate}}</td>
<td :data-label="$t('description')"> {{item.txDesc}}</td>
<td :data-label="$t('previousBalance')">{{item.txBalBefore}}</td>
<td :data-label="$t('debit')" v-if="item.txAmount <=0">{{ item.txAmount }}</td>
<td :data-label="$t('debit')" v-else>0.00</td>
<td :data-label="$t('credit')" v-if="item.txAmount > 0">{{item.txAmount}}</td>
<td :data-label="$t('credit')" v-else>0.00</td>
<td :data-label="$t('balance')">{{item.txBalAfter}}</td>
</tr>
</tbody>
</table>
I can't try your snippets. but please take a look if this is what you are expecting.
body{
box-sizing: border-box
border: 1px solid #ddd;
}
table {
font-family: Arial, Helvetica, sans-serif;
border-collapse:separate;
border-spacing:0 15px;
width: 100%;
border: none
}
table td, #customers th {
padding: 20px;
}
table tr {background-color: #eaeefa;}
table th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #d9dff3;
}
td:first-child,
th:first-child {
border-radius: 10px 0 0 10px;
}
td:last-child,
th:last-child {
border-radius: 0 10px 10px 0;
}
<table id="customers">
<tr>
<th>Name</th>
<th>Age</th>
<th>Role</th>
</tr>
<tr>
<td>Temitope</td>
<td>12</td>
<td>Accountant</td>
</tr>
<tr>
<td>Alfred</td>
<td>23</td>
<td>Designer</td>
</tr>
<tr>
<td>Bello</td>
<td>14</td>
<td>Painter</td>
</tr>
<tr>
<td>John</td>
<td>25</td>
<td>Architect</td>
</tr>
<tr>
<td>James</td>
<td>10</td>
<td>Manager</td>
</tr>
</table>
Let me know if you have any questions
I have an .xsl file to create 4 tables. Problem is: the contents of all the tables will be inserted automatically through an .xml file, so they are not fixed. In the example below, I insert certain contents and you see the widths of all the tables are not equal, the tables also do not stay in the middle of the page.
How should I update my CSS part below, so that with any inserted contents, all 4 tables have the same width and stay in the middle of the page?
.frame {
font-family: Verdana;
}
.div1 {
margin-right:80px;
margin-left:80px;
}
.div2 {
margin-right:80px;
margin-left:80px;
}
.div3 {
margin-right:80px;
margin-left:80px;
}
.div4 {
margin-right:80px;
margin-left:80px;
}
.table1 {
width: 760px;
margin: 0 auto;
border-collapse: collapse;
font-weight: bold;
}
.table1 td {
vertical-align: top;
padding-left: 6px;
padding-bottom: 5px;
border: 1px solid black;
width: 380px;
}
.table1 tr:nth-child(2) td {
border: none;
}
.table2 {
width: 760px;
margin: 0 auto;
border-collapse: collapse;
}
.table2 th {
vertical-align: top;
border: 1px solid black;
text-align: left;
padding-left: 6px;
font-weight: bold;
background-color: rgb(0,116,188);
color: white;
}
.table2 td {
vertical-align: top;
padding-left: 6px;
padding-bottom: 5px;
border: 1px solid black;
}
.table2 tr:nth-child(1) td {
border: none;
}
.table2 tr:nth-child(2) td {
border: none;
}
.table2 tr:nth-last-child() td {
border: none;
}
.table2 tr:nth-last-child(1) td {
border: none;
}
.table3 {
vertical-align: top;
width: 760px;
margin: 0 auto;
border-collapse: collapse;
}
.table3 th {
vertical-align: top;
border: 1px solid black;
text-align: left;
padding-left: 6px;
font-weight: bold;
background-color: rgb(0,116,188);
color: white;
}
.table3 td {
vertical-align: top;
padding-left: 6px;
padding-bottom: 5px;
border: 1px solid black;
}
.table3 tr:nth-child(1) td {
border: none;
}
.table3 tr:nth-child(2) td {
border: none;
}
.table3 tr:nth-child(3) td {
border: none;
}
.table3 tr:nth-child(4) td {
border: none;
}
.table3 tr:nth-child(5) td {
border: none;
}
.table3 tr:nth-last-child() td {
border: none;
}
.table3 tr:nth-last-child(1) td {
border: none;
}
.table4 {
vertical-align: top;
width: 760px;
margin: 0 auto;
border-collapse: collapse;
}
.table4 th {
vertical-align: top;
border: 1px solid black;
text-align: left;
padding-left: 6px;
font-weight: bold;
background-color: rgb(0,116,188);
color: white;
}
.table4 td {
vertical-align: top;
padding-left: 6px;
padding-bottom: 5px;
border: 1px solid black;
}
.table4 tr:nth-child(1) td {
border: none;
}
.table4 tr:nth-child(2) td {
border: none;
}
<div class="frame">
<div class="div1">
<table class="table1" style="margin-top:20px">
<tr>
<td>Contract</td>
<td>ABC XYZ</td>
</tr>
<tr>
<td> <br/> </td>
<td> <br/> </td>
</tr>
<tr>
<td>Informations about Patients of</td>
<td>Dr. William Hills (ID: 123456789)</td>
</tr>
<tr>
<td>Quartal/Year of treated Patient</td>
<td>Q4-2016</td>
</tr>
<tr>
<td>Treatment carried out by</td>
<td>Dr. William Hills (ID: 123456789)</td>
</tr>
<tr>
<td>Start date Import</td>
<td>201610011335</td>
</tr>
<tr>
<td>Quantity of enrolled Patients</td>
<td>126</td>
</tr>
</table>
</div>
<br/>
<br/>
<div class="div2">
<table class="table2" style="font-size:12pt">
<tr>
<td colspan="7" style="font-weight: bold; color:rgb(0,116,188)">Changes of following patients</td>
</tr>
<tr>
<td colspan="7"/>
</tr>
<tr>
<th>Name</th>
<th>Birthday</th>
<th>Insurance No.</th>
<th>Contractstatus</th>
<th>Begin date</th>
<th>End date</th>
<th>Reason</th>
</tr>
<tr>
<td>Frank Harrison</td>
<td>01.12.1959</td>
<td>G987654321</td>
<td>
<b>Activated</b>
</td>
<td>
<b>01.04.2017</b>
</td>
<td/>
<td/>
</tr>
<tr>
<td>Peter Smith</td>
<td>04.12.1969</td>
<td>G543267sfgsfgsgdgdfgssgs7895642gfdfsfsfsd89</td>
<td>
<b>Terminated</b>
</td>
<td>01.01.2016</td>
<td>
<b>31.03.2017</b>
</td>
<td>Cancelled</td>
</tr>
<tr>
<td colspan="7"> Some notations here</td>
</tr>
</table>
</div>
<br/>
<br/>
<div class="div3">
<table class="table3" style="font-size:12pt">
<tr>
<td colspan="6" style="margin-left:80px; font-weight:bold; color:rgb(0,116,188)">Title of second table</td>
</tr>
<tr>
<td colspan="6"/>
</tr>
<tr>
<td colspan="6">101 Dalmatians is a 1996 American live-action family comedy film based on Walt Disney's animated 1961 movie adaptation of Dodie Smith's 1956 novel The Hundred and One Dalmatians. Directed by Stephen Herek and co-produced by John Hughes and Ricardo Mestres, it stars Glenn Close, Hugh Laurie, Mark Williams, Tim McInnerny, Jeff Daniels and Joely Richardson. In contrast with the 1961 film, none of the animals talk in this version. Released on November 27, 1996 by Walt Disney Pictures, the film was praised for its faithfulness to the animated classic. It received mixed reviews, but was a commercial success, grossing $320.6 million in theaters against a $75 million budget. </td>
</tr>
<tr>
<td colspan="6"/>
</tr>
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<th>Name</th>
<th>Birthday</th>
<th>Insurance No.</th>
<th>Office</th>
<th>Date for Q4-2016</th>
<th>Reason</th>
</tr>
<tr>
<td>Adolph_Blaine_Charles_David_Earl_Frederick_Gerald_Hubert_Irvin_ John Kenneth Lloyd Martin Nero Oliver Paul</td>
<td>04.12.1969</td>
<td>G543996789</td>
<td>Activated<br/>
<b>01.07.2016</b>
</td>
<td>Activated<br/>
<b>01.04.2016</b>
<br/>
</td>
<td/>
</tr>
<tr>
<td>Peter Tester</td>
<td>01.12.1959</td>
<td>G987677321</td>
<td>
<b>Activated</b>
<br/>01.01.2016</td>
<td>
<b>Terminated</b>
<br/>
<b>01.01.2016</b>
<br/>
<b>30.06.2016</b>
</td>
<td>Late feedback about changing the residence</td>
</tr>
<tr>
<td colspan="6"> Some notations here</td>
</tr>
</table>
</div>
<br/>
<br/>
<div class="div4">
<table class="table4" style="font-size:12pt">
<tr>
<td colspan="4" style="font-weight: bold; color:rgb(0,116,188)">Title of third table</td>
</tr>
<tr>
<td colspan="4"/>
</tr>
<tr>
<th>Name</th>
<th>Birthday</th>
<th>Insurance No.</th>
<th>Notice</th>
</tr>
<tr>
<td>Fritz Ford</td>
<td>30.01.1965</td>
<td>D555555555</td>
<td>PTD</td>
</tr>
</table>
</div>
</div>
A quick and dirty solution would be to add table-layout:fixed;width:100% on all your tables. This way, the width will always be 100% and the table cell contents would wrap. Keep in mind that adding table-layout:fixed will make all table-cells have equal width.
Of course if your tables are too long you would need javascript to achieve what you are after.
I have a blog on Wordpress and I want to create a stylish colourful table on my blog please. Suggest me code for my blog
As #Alex pointed out, the material color palette is a modern and nice way to get colors. All you would need to do is apply it to the different segments of your table.
.myTable {
width: 500px;
border-collapse: collapse;
border-bottom: 1px solid #f44336;
font-family: sans-serif;
}
/* Header */
.myTable thead th {
background: #f44336;
color: #fff;
padding: 3em 1em 1em 1em;
font-weight: 400;
text-align: left;
}
.myTable thead th:nth-child(1) {
font-weight: 600;
}
/* Rows */
.myTable tbody tr td {
padding: 1em;
}
.myTable tbody tr:nth-child(even) td {
background: #ffcdd2;
}
.myTable tbody tr td:nth-child(1) {
font-weight: 600;
}
<table class="myTable">
<thead>
<tr>
<th>Row 1</th>
<th>Row 2</th>
<th colspan="2">Row 3 and 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>1,1</td>
<td>1,2</td>
<td>1,3</td>
<td>1,4</td>
</tr>
<tr>
<td>2,1</td>
<td>2,2</td>
<td>2,3</td>
<td>2,4</td>
</tr>
<tr>
<td>3,1</td>
<td>3,2</td>
<td>3,3</td>
<td>3,4</td>
</tr>
<tr>
<td>4,1</td>
<td>4,2</td>
<td>4,3</td>
<td>4,4</td>
</tr>
</tbody>
</table>
Below is a small simple table as an example. I want the header row to be of one color (grey). The alternate rows below header to be of another color (yellow). And the first column of another color (orange).
I am not able to achieve the desired results with the CSS. How do I go about it without individually coloring the cells.
Code in JSFiddle
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
padding: 5px;
}
table {
width: 100%;
}
th {
background-color: grey;
color: white;
}
tr:nth-child(odd) {
background-color: yellow;
}
<table>
<col style="background-color: orange;" />
<tr>
<th> </th>
<th>Bank</th>
<th>Amount</th>
</tr>
<tr>
<td>John</td>
<td>ABC</td>
<td>12345</td>
</tr>
<tr>
<td rowspan="2">David</td>
<td>DEF</td>
<td>456789</td>
</tr>
<tr>
<td>GHI</td>
<td>147258</td>
</tr>
<tr>
<td>Kevin</td>
<td>JKL</td>
<td>258369</td>
</tr>
<tr>
<td>Mike</td>
<td>MNO</td>
<td>369258</td>
</tr>
</table>
It's not a very good solution but here is a fix:
http://jsfiddle.net/sthmw0dk/2/
I have added the following lines:
tr td:first-child
{
background-color: orange;
}
tr:nth-child(even) td:nth-last-child(2)
{
background-color: white;
}
tr:nth-child(odd) td:nth-last-child(2)
{
background-color: yellow;
}
The last selector is necessary when you change your rowspan to 3 or more.
I would however suggest using classes for your first column. It will be a lot easier a better when you want to use more columns in the future.
demo - http://jsfiddle.net/victor_007/sthmw0dk/3/
The only thing i have changed is styling td instead of tr with background-color
Using td:not(:first-child) the first-child of tr will not get any styling
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
padding: 5px;
}
table {
width: 100%;
}
th {
background-color: grey;
color: white;
}
.first-col {
background-color: orange;
}
tr:nth-child(odd) td:not(:first-child) {
background-color: yellow;
}
<table>
<colgroup>
<col class="first-col" />
</colgroup>
<tr>
<th> </th>
<th>Bank</th>
<th>Amount</th>
</tr>
<tr>
<td>John</td>
<td>ABC</td>
<td>12345</td>
</tr>
<tr>
<td rowspan="2">David</td>
<td>DEF</td>
<td>456789</td>
</tr>
<tr>
<td>GHI</td>
<td>147258</td>
</tr>
<tr>
<td>Kevin</td>
<td>JKL</td>
<td>258369</td>
</tr>
<tr>
<td>Mike</td>
<td>MNO</td>
<td>369258</td>
</tr>
</table>
On an assignment for my teacher, we are making a table in which I want each td element to be 200px wide for a total of 5 cells which equal to 1000px (wrapper). When I do this however, the last td in each tr jumps down to the next line when they should all line up properly with no issues.
EDIT: Solved! (Read comments)
Here is my code for the table:
<table id="assignment-table">
<tr>
<th>Assignment</th>
<th>Fall 2013</th>
<th>Responsive?</th>
<th>Winter 2014</th>
<th>Responsive?</th>
</tr>
<tr>
<td>A1</td>
<td>Code Provided Site</td>
<td>No</td>
<td>Designasaurus</td>
<td>Yes</td>
</tr>
<tr>
<td>A2a</td>
<td>Restaurant Mock-up</td>
<td>N/a</td>
<td>TBA</td>
<td>-</td>
</tr>
<tr>
<td>A2b</td>
<td>Restaurant Static</td>
<td>No</td>
<td>TBA</td>
<td>-</td>
</tr>
<tr>
<td>A3a</td>
<td>Adaptive Excercise</td>
<td>No</td>
<td>TBA</td>
<td>-</td>
</tr>
<tr>
<td>A3b</td>
<td>Responsive Excercise</td>
<td>Yes</td>
<td>TBA</td>
<td>-</td>
</tr>
<tr>
<td>A4</td>
<td>Restaurant Final</td>
<td>Yes</td>
<td>TBA</td>
<td>-</td>
</tr>
<tr>
<td>A5a</td>
<td>Final Mock-up</td>
<td>N/a</td>
<td>TBA</td>
<td>-</td>
</tr>
<tr>
<td>A5b</td>
<td>Final Site</td>
<td>Yes</td>
<td>TBA</td>
<td>-</td>
</tr>
<tr>
<td class="lastrow">NSCC GRAPHIC DESIGN | 2012-14</td>
</tr>
</table>
</div>
And then the CSS:
#content {
width: 100%;
color: white;
}
#assignment-table {
font-size: 16px;
border-spacing: 0!important;
border-collapse: collapse;
}
#assignment-table th {
display: inline-block;
padding: 25px 0;
width: 200px;
text-align: center;
}
#assignment-table tr {
display: block;
border-bottom: 1px solid #ffffff;
}
#assignment-table tr:last-child {
width: 1000px;
border-bottom: none!important;
}
#assignment-table td {
display: inline-block;
padding: 25px 0;
width: 200px;
text-align: center;
}
.lastrow {
width: 1000px!important;
}
th:nth-child(3) {
background-color: rgba(255,255,255,0.05);
}
td:nth-child(3) {
background-color: rgba(255,255,255,0.05);
font-family: 'source_sans_proitalic';
}
th:nth-child(5) {
background-color: rgba(255,255,255,0.05);
}
td:nth-child(5) {
background-color: rgba(255,255,255,0.05);
font-family: 'source_sans_proitalic';
}
It should look like this:
It looks like you have display: inline-block; on your table cells. inline-block will automatically insert a space between elements. It's this space that is adding up and wrapping your last element. I would remove the display: inline-block; from your css entries, since this is a table it doesn't need it anyway.
CSS:
#assignment-table th {
//display: inline-block; <- remove this
padding: 25px 0;
width: 200px;
text-align: center;
}
#assignment-table td {
//display: inline-block; <- remove this
padding: 25px 0;
width: 200px;
text-align: center;
}
EXAMPLE FIDDLE
You are removing the default table behavior by using display: inline-block on tds. Just apply width: 1000px to the table and td { width: 20%; }
EDIT: here you go.