I am trying to overwrite a td style like this:
.valuator .sw-slots table, tr, td { width 100% }
so I did this:
td.license-name-td{
width: 100px !important;
}
The table took always the "global" style and overwrites, rather ignores my style. Even chrome doesn't cross the link out, it just ignores that part.
td.license-name-td {
width: 100px !important
}
.valuator .sw-slots table, tr, td {
width: 100%;
}
(Chrome computed css output)
Is there a special way to overwrite the td tag afterwards?
.valuator .sw-slots table, tr, td {
width: 100%;
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
border-collapse: collapse;
border-spacing: 0;
text-align: right;
color: #3c3c3c;
}
table.license-table td.license-name-td {
text-align: left !important;
word-break: break-word;
overflow: hidden;
width: 100px !important;
}
table.license-table td.license-td {
text-align: left !important;
margin-left: 3px;
word-break: break-word;
}
<table class="t3lsg license-table" style="font-size: 12px;">
<tbody><tr>
<th style="text-align: left;">Software</th>
<th style="text-align: left;">Version</th>
<th style="text-align: left;">Source</th>
<th style="text-align: left;">License</th>
</tr>
<tr>
<td colspan="4">
<div style="height: 1px; background-color: lightgrey; margin: 3px 0 3px 0;">
</div>
</td>
</tr>
<tr>
<td class="license-name-td">Fleck</td>
<td class="license-td">0.9.6.19</td>
<td class="license-td">https://github.com/statianzo/Fleck</td>
<td class="license-td">MIT License</td>
</tr>
<tr>
<td colspan="4">
<div style="height: 1px; background-color: lightgrey; margin: 3px 0 3px 0;">
</div>
</td>
</tr>
<tr>
<td class="license-name-td">HTML Agility Pack</td>
<td class="license-td">HAP 1.4.6</td>
<td class="license-td">http://code.google.com/p/heartcode-canvasloader/</td>
<td class="license-td">Microsoft Public License </td>
</tr>
<tr>
<td colspan="4">
<div style="height: 1px; background-color: lightgrey; margin: 3px 0 3px 0;">
</div>
</td>
</tr>
<tr>
<td class="license-name-td">jQuery</td>
<td class="license-td">1.10.2002</td>
<td class="license-td">http://jquery.com</td>
<td class="license-td">MIT License</td>
</tr>
<tr>
<td colspan="4">
<div style="height: 1px; background-color: lightgrey; margin: 3px 0 3px 0;">
</div>
</td>
</tr>
<tr>
<td class="license-name-td">jQuery Knob</td>
<td class="license-td">11.2.8</td>
<td class="license-td">http://anthonyterrien.com/knob</td>
<td class="license-td">MIT License</td>
</tr>
</table>
EDIT: I changed one mistake, that i forgot to change one inline style to a class, now this is the new result.
First, in your example code, I added the two enclosing div's (.valuator, .sw-slots) so that the first CSS rule applies to the table.
After that, you need to make sure that the widths of the table cell are set to a default of auto except for td.license-name-td which had a 100px width.
You need to reset the td for the separator td[colspan="4"] to width: auto and then the same for td.license-td.
I think this is what you need. Just be on the look out for other CSS rules that might be in hour style sheets that might override these.
.valuator .sw-slots table, tr, td {
width: 100%;
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
border-collapse: collapse;
border-spacing: 0;
text-align: right;
color: #3c3c3c;
}
td[colspan="4"] {
width: auto;
}
td.license-name-td {
text-align: left;
word-break: break-word;
overflow: hidden;
width: 100px;
background-color: lightblue;
}
td.license-td {
text-align: left;
margin-left: 3px;
word-break: break-word;
width: auto;
}
<div class="valuator">
<div class="sw-slots">
<table class="t3lsg" style="font-size: 12px;">
<tbody>
<tr>
<th style="text-align: left;">Software</th>
<th style="text-align: left;">Version</th>
<th style="text-align: left;">Source</th>
<th style="text-align: left;">License</th>
</tr>
<tr>
<td colspan="4">
<div style="height: 1px; background-color: lightgrey; margin: 3px 0 3px 0;">
</div>
</td>
</tr>
<tr>
<td class="license-name-td">Fleck</td>
<td class="license-td">0.9.6.19</td>
<td class="license-td">https://github.com/statianzo/Fleck</td>
<td class="license-td">MIT License</td>
</tr>
<tr>
<td colspan="4">
<div style="height: 1px; background-color: lightgrey; margin: 3px 0 3px 0;">
</div>
</td>
</tr>
<tr>
<td class="license-name-td">HTML Agility Pack</td>
<td class="license-td">HAP 1.4.6</td>
<td class="license-td">http://code.google.com/p/heartcode-canvasloader/</td>
<td class="license-td">Microsoft Public License</td>
</tr>
<tr>
<td colspan="4">
<div style="height: 1px; background-color: lightgrey; margin: 3px 0 3px 0;">
</div>
</td>
</tr>
<tr>
<td class="license-name-td">jQuery</td>
<td class="license-td">1.10.2002</td>
<td class="license-td">http://jquery.com</td>
<td class="license-td">MIT License</td>
</tr>
<tr>
<td colspan="4">
<div style="height: 1px; background-color: lightgrey; margin: 3px 0 3px 0;">
</div>
</td>
</tr>
<tr>
<td class="license-name-td">jQuery Knob</td>
<td class="license-td">11.2.8</td>
<td class="license-td">http://anthonyterrien.com/knob</td>
<td class="license-td">MIT License</td>
</tr>
</table>
</div>
</div>
i've added a class name to my table and changed the class names to:
table.license-table td.license-td{
text-align: left !important;
margin-left:3px;
word-break: break-word;
width: 100px !important;
}
table.license-table td.license-name-td{
text-align: left !important;
word-break: break-word;
overflow: hidden;
width: 100px !important;
}
this solves my problem.
The problem is that the width: 100% also applies to the table. And because a all cells in a row must count up to the width of the table, it will not work to just restrict the width of the cell, you also must address the table, or the other cells in the row.
I do not know what your HTML looks like, but if the cell is the only one in the row, you could add a class to the table instead of the cell and set the width of the table to 100px in the same way as you did for the cell, you do not have to restrict the width of the cell than, as that will be automatically.
Related
I have placed the image but it breaks when we resize the window.
I want it in the center of the first column which is description below the email service.
I want it to remain in the center all the time.
I have given the td position relative and made the image absolute position. Its relative to the td................................
* {
font-family: sans-serif;
}
table{
width: 100%;
border: 1px solid #edf2fc;
border-collapse: collapse;
margin-top: 30px;
}
table th {
padding: 11px 6px 11px 6px;
word-break: break-all;
background: #413fa4;
color: #fff;
text-align: center;
}
tr td {
border: 1px solid #cbdaf1;
}
table tbody td {
text-align: center;
padding: 33px 0 33px 0;
word-break: break-all;
font-size: 18px;
}
tfoot tr td {
padding-top: 4px;
padding-bottom: 4px;
}
tfoot tr td:first-child{
padding-right: 22px;
}
.gray {
background-color: lightgray
}
<table width="100%">
<thead style="background-color: lightgray;">
<tr>
<th>Description</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
<tr>
<td style="position: relative">Email Service
<img style="position: absolute; left: 300px; top: 70px;" src="https://image.shutterstock.com/image-vector/paid-thank-you-grunge-rubber-260nw-564254104.jpg"width=130px;>
</td>
<td align="center">1400.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="right">Subtotal</td>
<td align="center">1635.00</td>
</tr>
<tr>
<td align="right">Tax</td>
<td align="center">294.3</td>
</tr>
<tr>
<td align="right">Discount</td>
<td align="center">294.3</td>
</tr>
<tr>
<td align="right">Total</td>
<td align="center" class="gray">$ 1929.3</td>
</tr>
</tfoot>
</table>
Wrap the text and the image inside a div with a flex box property, and then you can center it as you like
* {
font-family: sans-serif;
}
table{
width: 100%;
border: 1px solid #edf2fc;
border-collapse: collapse;
margin-top: 30px;
}
table th {
padding: 11px 6px 11px 6px;
word-break: break-all;
background: #413fa4;
color: #fff;
text-align: center;
}
tr td {
border: 1px solid #cbdaf1;
}
table tbody td {
text-align: center;
padding: 33px 0 33px 0;
word-break: break-all;
font-size: 18px;
}
tfoot tr td {
padding-top: 4px;
padding-bottom: 4px;
}
tfoot tr td:first-child{
padding-right: 22px;
}
.gray {
background-color: lightgray
}
.flex-b {
display:flex;
align-items:center;
justify-content:center;
}
<table width="100%">
<thead style="background-color: lightgray;">
<tr>
<th>Description</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="flex-b">
<span>Email Service</span>
<img src="https://image.shutterstock.com/image-vector/paid-thank-you-grunge-rubber-260nw-564254104.jpg"width=130px;>
</div>
</td>
<td align="center">1400.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="right">Subtotal</td>
<td align="center">1635.00</td>
</tr>
<tr>
<td align="right">Tax</td>
<td align="center">294.3</td>
</tr>
<tr>
<td align="right">Discount</td>
<td align="center">294.3</td>
</tr>
<tr>
<td align="right">Total</td>
<td align="center" class="gray">$ 1929.3</td>
</tr>
</tfoot>
</table>
I want to display records one by one in sequence, I do not know why the extra space appears between the records. Can anyone help me please?
{block name=head}
<style>
td {
border: none;
font-weight: bold;
font-size: 100%;
}
.h1 {
margin: 3px, 0px;
}
.content {
height: 270px;
border: 1px solid black;
font-size: 100%;
width: 80%;
margin: 0 auto;
border-top: none;
font-family: Times New Roman;
}
.footer {
height: 30px;
border: 1px solid black;
width: 80%;
margin: 0 auto;
font-family: Terminal;
}
.details-table {
border-collapse: collapse;
}
.details-table td {
border-bottom: 1px solid #666;
padding: 5px;
border-right: 1px solid #666;
}
.details-table td.no-right-border {
border-right: none;
}
.details-table td.no-bottom-border {
border-bottom: none;
}
</style>
{/block}
{block name=body}
<div class="footer">
<table align="center" width="80%">
<tr>
<td style="text-align:left;">Name : {$partyName}</td>
<td style="text-align:center;">Date : {$salesDate}</td>
<td style="text-align:right;">Fine : {$totFine|string_format:"%.3f"}</td>
</tr>
</table>
</div>
<div class="content">
<table align="center" width="100%" class="details-table">
<tr height="30">
<td>Item</td>
<td style="text-align:center;">Gross</td>
<td style="text-align:center;">Less</td>
<td style="text-align:center;">Net</td>
<td style="text-align:center;">Touch</td>
<td style="text-align:center;">Wastage</td>
<td style="text-align:center;">Fine</td>
</tr>
{section name="sec" loop=$dtArray}
<tr>
<td valign="top" class="no-bottom-border">{$dtArray[sec].itemId}</td>
<td valign="top" style="text-align:center;" class="no-bottom-border">{$hsnCode}</td>
<td valign="top" style="text-align:center;" class="no-bottom-border">{$fine}</td>
<td valign="top" style="text-align:center;" class="no-bottom-border">{$rate}</td>
<td valign="top" style="text-align:center;" class="no-bottom-border">{$amount|string_format:"%.2f"}</td>
<td valign="top" style="text-align:center;" class="no-bottom-border">{$amount|string_format:"%.2f"}</td>
<td valign="top" style="text-align:center;" class="no-bottom-border">{$amount|string_format:"%.2f"}</td>
</tr>
{/section}
</table>
</div>
{/block}
You have height:270px set on the <div class="content">, and height="100%" set on the <table>, and the table is an immediate child of that div, so it inherits the height. That's why you're seeing the extra space when there are only a couple of rows. Simply reset or remove either of the height value to fix that.
EDIT
In the other case, if you want to keep the height set on the table, and only have the empty space to display at the bottom, you can add an empty row and set it to height:100%.
.details-table {
height: 270px;
width: 80%;
margin: 0 auto;
border-collapse: collapse;
}
.details-table td {
border: 1px solid #666;
padding: 5px;
}
<table class="details-table">
<tr>
<td>Item</td>
<td>Gross</td>
<td>Less</td>
<td>Net</td>
<td>Touch</td>
<td>Wastage</td>
<td>Fine</td>
</tr>
<tr>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
<!-- insert empty row -->
<tr style="height:100%;">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
I have the following code in a html email:
<table style="margin: 32px 0; border: 0; border-spacing: 0; border-collapse: collapse;">
<tr>
<td style="width: 50%; vertical-align: top; padding: 0; border: 0; line-height: 1; background: red;">Invoice Number</td>
<td style="width: 50%; vertical-align: top; padding: 0; border: 0; line-height: 1; background: red;"></td>
</tr>
<tr>
<td style="width: 50%; vertical-align: top; padding: 0; border: 0; line-height: 1; background: red;">Tax Point</td>
<td style="width: 50%; vertical-align: top; padding: 0; border: 0; line-height: 1; background: red;">30/11/2017 11:48:32</td>
</tr>
<tr>
<td style="width: 50%; vertical-align: top; padding: 0; border: 0; line-height: 1; background: red;">Payer ID</td>
<td style="width: 50%; vertical-align: top; padding: 0; border: 0; line-height: 1; background: red;">Senior Internet</td>
</tr>
</table>
<table class="invoice-items">
<tr>
<th style="font-family: sans-serif; padding: 10px;">Description</th>
<th style="font-family: sans-serif; padding: 10px;">Item Amount</th>
<th style="font-family: sans-serif; padding: 10px;">Quantity</th>
<th style="font-family: sans-serif; padding: 10px;">VAT Amount</th>
<th style="font-family: sans-serif; padding: 10px;">Line Total</th>
</tr>
<tr>
<td style="padding: 10px;">Charity/ public sector</td>
<td style="padding: 10px;">360.0000</td>
<td style="padding: 10px;">1</td>
<td style="padding: 10px;">72.0000</td>
<td style="padding: 10px;">360.0000</td>
</tr>
<tr>
<td colspan="3" class="empty"> </td>
<td class="no-border">Total</td>
<td class="green no-border">£432.0000</td>
</tr>
</table>
However, I am having an issue with the cell height of the first table coming out far too large. I've tried setting padding, borders, line heights, I just can't get the red cells to be the height of the text within them.
It's something about the CSS you're using or the email client, your code is working properly here, checkout how it is rendered in plain HTML file:
Check out this answer for testing HTML templates:
https://stackoverflow.com/a/1019166/4129382
I have a table of fixed width and height containing three rows and columns. Rows and columns are automatically equal size, but when I put innerHTML (or image) into table cell, cell with text inside expands at the cost of other columns. How to prevent table cells from expanding after inserting content inside? I've tried solutions from similar stack overflow questions, but nothing worked.
JS fiddle: https://jsfiddle.net/m20akmdx/14/
document.getElementById('8').innerHTML = 'R';
table {
width: 360px;
height: 360px;
border: 1px solid black;
border-collapse: collapse;
}
td {
border: 1px solid black;
text-align: center;
}
<table id="table">
<tr>
<td id="1"></td>
<td id="2"></td>
<td id="3"></td>
</tr>
<tr>
<td id="4"></td>
<td id="5"></td>
<td id="6"></td>
</tr>
<tr>
<td id="7"></td>
<td id="8"></td>
<td id="9"></td>
</tr>
</table>
Try using fixed table layout.
table {
table-layout: fixed;
...
}
And adding a no-break space into each cell.
td:after {
content: "\00A0";
}
document.getElementById('8').innerHTML = 'R';
table {
table-layout: fixed;
width: 360px;
height: 360px;
border: 1px solid black;
border-collapse: collapse;
}
td {
border: 1px solid black;
text-align: center;
}
td:after {
content: "\00A0";
}
<table id="table">
<tr>
<td id="1"></td>
<td id="2"></td>
<td id="3"></td>
</tr>
<tr>
<td id="4"></td>
<td id="5"></td>
<td id="6"></td>
</tr>
<tr>
<td id="7"></td>
<td id="8"></td>
<td id="9"></td>
</tr>
</table>
Set the width and height of the td elements rather than a width and height for the table and you will get the desired behaviour.
document.getElementById('8').innerHTML = 'Raaaa';
table{
border: 1px solid black;
border-collapse: collapse;
}
td{
width:120px;
height:120px;
border: 1px solid black;
text-align: center;
}
<table id="table">
<tr>
<td id="1"></td>
<td id="2"></td>
<td id="3"></td>
</tr>
<tr>
<td id="4"></td>
<td id="5"></td>
<td id="6"></td>
</tr>
<tr>
<td id="7"></td>
<td id="8"></td>
<td id="9"></td>
</tr>
</table>
set a max-width
td{
border: 1px solid black;
text-align: center;
max-width: 200px;
}
or
td{
border: 1px solid black;
text-align: center;
max-width: 30%;
}
You will need to specify the td width, and maybe the height as well:
https://jsfiddle.net/m20akmdx/23/
document.getElementById('8').innerHTML = 'my long text gets wrapped';
table {
width: 360px;
height: 360px;
border: 1px solid black;
border-collapse: collapse;
}
td {
width: calc(100% / 3);
height: calc(100% / 3);
border: 1px solid black;
text-align: center;
}
<table id="table">
<tr>
<td id="1"></td>
<td id="2"></td>
<td id="3"></td>
</tr>
<tr>
<td id="4"></td>
<td id="5"></td>
<td id="6"></td>
</tr>
<tr>
<td id="7"></td>
<td id="8"></td>
<td id="9"></td>
</tr>
</table>
I'm creating an e-mail template to send out but for some reason, I am unable to create two simple columns in the footer area.
Layout:
Code:
<div style="width: 100%; height: 100%;">
<table style="margin: 0px auto 0px auto; padding: 20px 20px 20px 20px; font: normal 10.5px; color: #777777; width: 100%; height: 100%;" align="center">
<tbody>
<tr>
<td>
<table class="content" style="background: none repeat scroll 0% 0% #FFFFFF; box-shadow: 0px 1px 2px rgba; width: 600px; max-width: 600px; margin: 0px auto;" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
<thead>
<tr style="display: inline-block; width: 100%; background: #1F1F1F;" bgcolor="#1F1F1F">
<td style="width: 100%;" align="left" valign="middle">
<h1 style="padding: 15px 15px 15px 15px; color: #FFFFFF;">Test</h1>
</td>
<td style="border-left: 1px solid #FFFFFF;" align="right">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="text-decoration: none; color: #ffffff; text-align: center; padding: 15px 15px 15px 15px; border-bottom: 1px solid #FFFFFF; font-family: Helvetica, Arial, Verdana; font-size: 8px; letter-spacing: 1.5px;">test</td>
</tr>
<tr>
<td style="text-decoration: none; color: #ffffff; text-align: center; padding: 15px 15px 15px 15px; font-family: Helvetica, Arial, Verdana; font-size: 8px; letter-spacing: 1.5px;">test</td>
</tr>
</tbody>
</table>
</td>
</tr>
</thead>
<tbody>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<h4 style="color: #27ccc0; text-align: center; padding: 15px 15px 0px 15px;"> </h4>
</td>
</tr>
<tr>
<td> </td>
</tr>
</tbody>
<tfoot>
<tr>
<td>test</td>
<td>test</td>
</tr>
</tfoot>
</table>
</td>
</tr>
</tbody>
</table>
How do I modify the above code to create two simple columns in the footer area, that is still within the e-mail's container?
You should make simple structure of html,
Don't make table in table. You can use rowspan. HTML <th> rowspan Attribute
cells in thead tag, recommend to use th tag HTML <thead> Tag
Don't use this style display:inline-block; on tr tag
Put color style on tr tag if cells doesn't have different color
<div style="width: 100%; height: 100%;">
<table class="content" style="background: none; box-shadow: 0px 1px 2px rgba; width: 600px; max-width: 600px; margin: 0px auto;" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
<thead>
<tr style="width: 100%; background: #1F1F1F;color: #FFFFFF;">
<th style="width: 100%;" align="left" valign="middle" rowspan=2>
<h1 style="padding: 15px 15px 15px 15px;">test</h1>
</th>
<th style="border-left: 1px solid #FFFFFF;border-bottom: 1px solid #FFFFFF;text-decoration: none;text-align: center; padding: 15px 15px" align="right">
test
</th>
</tr>
<tr style="width: 100%; background: #1F1F1F;color: #ffffff; ">
<th style="border-left: 1px solid #FFFFFF;text-decoration: none; text-align: center; padding: 15px 15px" align="right">
test
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="background: red;" colspan="2"> </td>
</tr>
<tr>
<td style="background: red;" colspan="2"> </td>
</tr>
<tr>
<td style="background: red;" colspan="2">
<h4 style="color: #27ccc0; text-align: center; padding: 15px 15px 0px 15px;"> </h4>
</td>
</tr>
<tr>
<td style="background: red;" colspan="2"> </td>
</tr>
</tbody>
<tfoot>
<tr style="width: 100%; background: #1F1F1F; color: #ffffff;">
<td>test</td>
<td>test</td>
</tr>
</tfoot>
</table>
</div>
jsfiddle