Styling DIVs inside Tables - html

I am trying to define a weekly calendar, have a table with seven columns (one per day) and 24 rows (one per half an hour):
.cal-week {
border-collapse: collapse;
}
.cal-week-day {
width: 14%;
}
.cal-week-hour > td {
border: solid 1px #d8d8d8;
height: 2.2em;
position: relative;
}
.cal-week-hour > td > div {
position: absolute;
top: 0px;
z-index: 5;
width: 100%;
}
.item {
background-color: #494C4F;
color: #f4f4f4;
border: solid 1px #c8c8c8;
}
.item > div {
white-space: nowrap;
}
<table class="cal-week" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<th class="cal-week-day">
monday
</th>
<th class="cal-week-day">
tuesday
</th>
<th class="cal-week-day">
wednesday
</th>
</tr>
<tr class="cal-week-hour">
<td>
<div/>
</td>
<td>
<div/>
</td>
<td>
<div/>
</td>
</tr>
<tr class="cal-week-hour">
<td>
<div/>
</td>
<td>
<div>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td class="item" width="33.333333333333336%" >
<div>a long description</div>
</td>
<td class="item" width="33.333333333333336%" >
<div>normal desc</div>
</td>
<td class="item" width="33.333333333333336%" >
<div>short</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td>
<div/>
</td>
</tr>
<tr class="cal-week-hour">
<td>
<div/>
</td>
<td>
<div/>
</td>
<td>
<div/>
</td>
</tr>
<tr class="cal-week-hour">
<td>
<div/>
</td>
<td>
<div/>
</td>
<td>
<div/>
</td>
</tr>
<tr class="cal-week-hour">
<td>
<div/>
</td>
<td>
<div>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td class="item">
<div>asdsad</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td>
<div/>
</td>
</tr>
</tbody>
</table>
I am using React, the percentage of the tds of the inner tables are calculated as 100 / numberOfItems, in this example since we have 3 items -> 33.333333%. The problem is that the divs can be wider than the tds and as you can see in the fiddler they span over the next column.
The desired output is the following:
In fact, I have to draw n boxes which have to fit the parent (td) width, which in this case is dynamic. Furthermore, it should be responsive, so I cannot use static widths.
Any hints how to achieve such a result?

You can make the .item class into an inline-block element which will fix the 33% width.
Also because the border is added after the 33% width, your item is a bit to wide (it will be 33% + 1px left-border + 1px-right border).
you should consider giving the .item class a box-sizing: border-box; so the border will be inside this 33% width.
After this you get your desired output. See fiddle: https://jsfiddle.net/d2burtaz/
I also changed your min-height from those td's from 141px to 41px so it looks more like the picture you added.
-- Can you give me an example using just divs? question by Emaborsa.
Ofcourse, I would just remove the inner table with all its table elements, also remove the empty div's. And change the <td>'s into <div>'s. The only thing I have added after this is a .w-100 class which I added to the outer div so the 33% width on the inner children works.
.cal-week {
border-collapse: collapse;
font-size: 14px;
font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
}
.cal-week-top {
font-weight: normal;
text-align: left;
color: #444;
padding: 2px;
text-transform: uppercase;
}
.cal-week-day {
width: 14%;
}
.cal-week-day-link:hover {
cursor: pointer;
text-decoration: underline;
}
.cal-week-weeksel div {
width: 16px;
}
.cal-week-weeksel:hover {
cursor: pointer;
background-color: var(--hover-light);
}
.cal-week-time00 {
text-align: right;
border-right: solid 1px #d8d8d8);
border-left: solid 1px #d8d8d8;
padding: 1px 5px 2px 5px;
}
.cal-week-hour00 > td,
.cal-week-time {
border-top: solid 1px #d8d8d8;
border-bottom: dashed 1px #d8d8d8;
}
.cal-week-hour30 > td{
border-bottom: solid 1px #d8d8d8;
}
.cal-week-time30,
.cal-week-cell {
border-right: solid 1px #d8d8d8;
border-left: solid 1px #d8d8d8;
height: 2.2em;
}
.cal-week-cell {
position: relative;
}
.cal-week-cell > div {
position: absolute;
top: 0px;
z-index: 5;
width: 100%;
}
.cal-week-today {
background-color: var(--button-border-disabled);
}
.item {
background-color: #494C4F;
color: #f4f4f4;
padding: 1px 2px 2px 2px;
border: solid 1px #c8c8c8;
display: inline-block;
box-sizing: border-box;
}
.item a {
color: #f4f4f4;
}
.item a:hover {
text-decoration: underline;
}
.w-100{
width: 100%;
}
<table class="cal-week" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<th class="cal-week-top cal-week-day">
<div class="cal-week-day-link">26. Dienstag</div>
</th>
<th class="cal-week-top cal-week-day">
<div class="cal-week-day-link">27. Mittwoch</div>
</th>
<th class="cal-week-top cal-week-day">
<div class="cal-week-day-link">28. Donnerstag</div>
</th>
</tr>
<tr class="cal-week-hour00">
<td class="cal-week-cell">
<div/>
</td>
<td class="cal-week-cell">
<div/>
</td>
<td class="cal-week-cell">
<div/>
</td>
</tr>
<tr class="cal-week-hour30">
<td class="cal-week-cell">
<div/>
</td>
<td class="cal-week-cell">
<div class="w-100">
<div class="item single" title="10:30 - 14:25 Titel (Beschreibung)" style="min-height: 41px; width: 33.333336%;">
Titel
<div>Beschreibung</div>
</div><div class="item single" title="10:30 - 14:25 Titel (Beschreibung)" style="min-height: 41px; width: 33.333336%;">
Titel
<div>Beschreibung</div>
</div><div class="item single" title="10:30 - 14:25 Titel (Beschreibung)" style="min-height: 41px; width: 33.333336%;">
Titel
<div>Beschreibung</div>
</div>
</div>
</td>
<td class="cal-week-cell">
<div/>
</td>
</tr>
<tr class="cal-week-hour00">
<td class="cal-week-cell">
<div/>
</td>
<td class="cal-week-cell">
<div/>
</td>
<td class="cal-week-cell">
<div/>
</td>
</tr>
<tr class="cal-week-hour30">
<td class="cal-week-time30"/>
<td class="cal-week-cell">
<div/>
</td>
<td class="cal-week-cell">
<div/>
</td>
</tr>
<tr class="cal-week-hour00">
<td class="cal-week-cell">
<div/>
</td>
<td class="cal-week-cell">
<div>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td class="item single" title="12:26 - 13:26 sdsdsd (asdsad)" width="100%" style="min-height: 61px;">
<div>
<div>
sdsdsd
</div>
<div>asdsad</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td class="cal-week-cell">
<div/>
</td>
</tr>
</tbody>
</table>

Related

How can I make a Table mobile responsive

I am trying to make a table mobile responsive. The first thing I would love to do is to decrease the width size of the table headings and then enable the table data to have one complete row for each data.
I am trying to get my table to look like the attached picture on mobile.
.email-table table{
margin-left: 40px;
font-family: 'Roboto', sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border-top: 1px solid #dddddd;
border-bottom: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
td{
font-size: 1.2rem;
}
td:last-of-type{
font-weight: 700;
}
.attachment{
display: flex;
justify-content: center;
width: 20%;
align-items: center;
}
.first-clip span:last-of-type{
margin-right: 20px;
}
.last-clip{
margin-left: 25px;
}
.attachment span:last-of-type{
flex-shrink: 0;
}
.attachment span:first-of-type img{
width: 20px;
height: 20px;
}
.text-attachment{
display: flex;
justify-content: space-around;
}
.text-attachment span:first-of-type{
transform: translateX(-18px);
}
.second-text{
transform: translateX(5px);
}
.text-attachment span:last-of-type{
border: 1px solid #ccc;
background-color: #5E5D5D;
color: white;
border-radius: 5px;
padding: 0px 5px;
}
.second-text span:last-of-type{
transform: translateX(-10px);
}
td img{
width: 20px;
height: 20px;
transform: translateX(-30px);
}
th{
background-color: #EEEDED;
border-top: 3px solid #dddddd;
border-bottom: 3px solid #dddddd;
}
th:not(:last-child){
color: #5E5D5D;
}
.date>span img{
height: 10px;
width: 10px;
padding-left: 3px;
}
tr:not(:first-of-type):hover{
cursor: pointer;
color: blue;
background-color: #EEEDED;
}
<div class="email-table">
<table>
<tr>
<th>From</th>
<th>To</th>
<th>Subject</th>
<th class="date">Date <span><img src="./assets/icon_arrow01.svg" alt=""></span></th>
</tr>
<tr>
<td>aaa#example.com</td>
<td>zzz.zzz#example.com</td>
<td>[ HR-888 ] Notice of official announcement</td>
<td>0:20</td>
</tr>
<tr>
<td>bbb.bbbb#exam... </td>
<td>yyy#example.com</td>
<td>[web:333] "Web Contact"</td>
<td>0:10</td>
</tr>
<tr>
<td>ccc#example.com </td>
<td>
<div class="text-attachment">
<span>xxx#example.com, ...</span>
<span>+1</span>
</div>
</td>
<td>Happy New Year! Greetings for the New Year.</td>
<td>
<div class="attachment first-clip">
<span><img src="./assets/icon_clip.svg" alt=""></span>
<span>0:00</span>
</div>
</td>
</tr>
<tr>
<td>ddd.dddd#exam...</td>
<td>
<div class="text-attachment second-text">
<span>vvv.vvv#example.com, ... </span>
<span>+1</span>
</div>
</td>
<td>[HR-887(Revised: Office Expansion Project Team)] Notice of off... </td>
<td>Jan 01 </td>
</tr>
<tr>
<td>eee#example.com</td>
<td>
<div class="text-attachment">
<span>sss#example.com, .... </span>
<span>+2</span>
</div>
</td>
<td>[Github] Logout page</td>
<td>Jan 01</td>
</tr>
<tr>
<td>fff.ffff#example.c... </td>
<td>qqq.qqq#example.com</td>
<td>[dev] Postfix 3.1.12 / 3.2.9 / 3.3.4 / 3.4.5</td>
<td>Jan 01</td>
</tr>
<tr>
<td>ggg#example.com </td>
<td>ppp#example.com</td>
<td>Re: [Github] Brush-up on loading animation </td>
<td>Jan 01</td>
</tr>
<tr>
<td>hhh.hhh#examp...</td>
<td>ooo.ooo#example.com</td>
<td>Workplace Summary for sample, Inc.: Jun 2 - Jun 9</td>
<td>
<div class="attachment">
<span><img src="./assets/icon_clip.svg" alt=""></span>
<span>Jan 01</span>
</div>
</td>
</tr>
<tr>
<td>iii#example.com</td>
<td>nnn#example.com</td>
<td>I love you</td>
<td>
<div class="attachment last-clip">
<span><img src="./assets/icon_clip.svg" alt=""></span>
<span>2019/12/31</span>
</div>
</td>
</tr>
<tr>
<td>Pablo-Diego-...</td>
<td>Pablo-Diego-José-Francisc...
</td>
<td>[info:888] ABC EQUIPMENT COMPANY</td>
<td>2019/12/31</td>
</tr>
</table>
</div>
I, first of all, tried to make the header much smaller but that does not even work. I am totally lost at the steps I need to take to make this look good on mobile.
The trick for this sort of layout is to throw away the default table styling entirely.
Use display: contents to stop the tbody element from generating a box. Then use display: flex on the table to make it lay out the tr elements in a non-tabular column.
Then each tr can be styled as a CSS Grid, and the various elements positioned on that.
#media screen and (max-width: 1000px) {
body {
background: #AAA
}
table {
display: flex;
flex-direction: column;
margin: 0 10%;
background: white;
}
tbody,
tfoot {
display: contents;
}
thead {
display: none;
}
tr {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
gap: 1px 1px;
grid-template-areas: "From Date" "To Date" "Subject Date";
border-bottom: solid #aaa 1px;
}
td {
padding: 3px;
}
td:nth-child(1) {
grid-area: From;
}
td:nth-child(2) {
grid-area: To;
}
td:nth-child(3) {
grid-area: Subject;
}
td:nth-child(4) {
grid-area: Date;
text-align: right;
}
}
<div class="email-table">
<table>
<thead>
<tr>
<th>From</th>
<th>To</th>
<th>Subject</th>
<th class="date">Date <span><img src="./assets/icon_arrow01.svg" alt=""></span></th>
</tr>
</thead>
<tr>
<td>aaa#example.com</td>
<td>zzz.zzz#example.com</td>
<td>[ HR-888 ] Notice of official announcement</td>
<td>0:20</td>
</tr>
<tr>
<td>bbb.bbbb#exam... </td>
<td>yyy#example.com</td>
<td>[web:333] "Web Contact"</td>
<td>0:10</td>
</tr>
<tr>
<td>ccc#example.com </td>
<td>
<div class="text-attachment">
<span>xxx#example.com, ...</span>
<span>+1</span>
</div>
</td>
<td>Happy New Year! Greetings for the New Year.</td>
<td>
<div class="attachment first-clip">
<span><img src="./assets/icon_clip.svg" alt=""></span>
<span>0:00</span>
</div>
</td>
</tr>
<tr>
<td>ddd.dddd#exam...</td>
<td>
<div class="text-attachment second-text">
<span>vvv.vvv#example.com, ... </span>
<span>+1</span>
</div>
</td>
<td>[HR-887(Revised: Office Expansion Project Team)] Notice of off... </td>
<td>Jan 01 </td>
</tr>
<tr>
<td>eee#example.com</td>
<td>
<div class="text-attachment">
<span>sss#example.com, .... </span>
<span>+2</span>
</div>
</td>
<td>[Github] Logout page</td>
<td>Jan 01</td>
</tr>
<tr>
<td>fff.ffff#example.c... </td>
<td>qqq.qqq#example.com</td>
<td>[dev] Postfix 3.1.12 / 3.2.9 / 3.3.4 / 3.4.5</td>
<td>Jan 01</td>
</tr>
<tr>
<td>ggg#example.com </td>
<td>ppp#example.com</td>
<td>Re: [Github] Brush-up on loading animation </td>
<td>Jan 01</td>
</tr>
<tr>
<td>hhh.hhh#examp...</td>
<td>ooo.ooo#example.com</td>
<td>Workplace Summary for sample, Inc.: Jun 2 - Jun 9</td>
<td>
<div class="attachment">
<span><img src="./assets/icon_clip.svg" alt=""></span>
<span>Jan 01</span>
</div>
</td>
</tr>
<tr>
<td>iii#example.com</td>
<td>nnn#example.com</td>
<td>I love you</td>
<td>
<div class="attachment last-clip">
<span><img src="./assets/icon_clip.svg" alt=""></span>
<span>2019/12/31</span>
</div>
</td>
</tr>
<tr>
<td>Pablo-Diego-...</td>
<td>Pablo-Diego-José-Francisc...
</td>
<td>[info:888] ABC EQUIPMENT COMPANY</td>
<td>2019/12/31</td>
</tr>
</table>
</div>

Show tooltip(in span) always top in table

Hello I have a table and I made a tooltip with CSS
its shows up when u hover mouse on <td>
here's my jsfiddle : www.jsfiddle.net/4qzurb5w/
How can I make this tooltip always shows up everything in table?
Get rid of this block, it is conflicting:
.green:hover,
.blue:hover,
.red:hover,
.yellow:hover,
.black:hover {
opacity: 0.8;
}
It should work then.
I moved your opacity style to .tooltip .tooltiptext, see stack snippet.
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
opacity: 0.8; /* <-- I added your opacity here */
/* Position the tooltip */
position: absolute;
z-index: 1;
top: 100%;
left: 50%;
margin-left: -60px;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
.div table {
font-family: Arial, Helvetica, sans-serif;
color: #666;
font-size: 10px;
text-shadow: 1px 1px 0px #fff;
background: #eaebec;
border: #ccc 1px solid;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 1px 2px #d1d1d1;
-webkit-box-shadow: 0 1px 2px #d1d1d1;
box-shadow: 0 1px 2px #d1d1d1;
}
.div table caption {
font-weight: bold;
font-size: 11px;
}
.div td {
min-width: 100px;
text-align: center;
padding: 5px;
border-top: 1px solid #ffffff;
border-bottom: 1px solid #e0e0e0;
border-left: 1px solid #e0e0e0;
background: #fafafa;
background: -webkit-gradient(linear, left top, left bottom, from(#fbfbfb), to(#fafafa));
background: -moz-linear-gradient(top, #fbfbfb, #fafafa);
}
.red {
background: #940000 !important;
color: White !important;
text-shadow: 1px 1px 0px #000000;
}
.blue {
background: #1C2CFA !important;
color: White !important;
text-shadow: 1px 1px 0px #000000;
}
.black {
background: #000000 !important;
color: White !important;
text-shadow: 1px 1px 0px #000000;
}
.yellow {
background: #009999 !important;
color: Green !important;
text-shadow: 1px 1px 0px #000000;
}
.white {
background: #fafafa !important;
color: #666 !important;
}
.grey {
background: #808080 !important;
color: White !important;
text-shadow: 1px 1px 0px #000000;
}
.ariza {
background: #990000 !important;
color: White !important;
text-shadow: 1px 1px 0px #000000;
}
.green {
background: #00941C !important;
color: White !important;
text-shadow: 1px 1px 0px #000000;
}
.green:hover,
.blue:hover,
.red:hover,
.yellow:hover,
.black:hover {
/* opacity: 0.8; get rid of this */
}
.green a,
.blue a,
.red a,
.yellow a,
.black a {
display: block;
color: White;
text-decoration: none;
}
.yazitd {
width: 70px !important;
}
.sagtd {
width: 540px !important;
}
.tarihtd {
width: 160px !important;
}
.style3 {
width: 90px;
}
.style4 {
height: 19px;
}
.style5 {
width: 40px;
}
.style6 {
width: 40px;
height: 23px;
}
.style7 {
height: 23px;
}
<table>
<tbody>
<tr>
<td style="vertical-align: middle; min-width: 50px !important; font-weight: bold;">KAT 1 </td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="red tooltip">Daire No:1
<div><span class="tooltiptext">ALEX DE SOUZA<br>HASAN ALİ KALDIRIM<br>ALPER POTUK<br>RIDVAN DİLMEN<br></span></div>
</td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="green tooltip">Daire No:2
<div><span class="tooltiptext"></span></div>
</td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="red tooltip">Daire No:3
<div><span class="tooltiptext">ALİ KOÇ<br></span></div>
</td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="green tooltip">Daire No:4
<div><span class="tooltiptext"></span></div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="vertical-align: middle; min-width: 50px !important; font-weight: bold;">KAT 2 </td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="green tooltip" style="font-weight: 400;">Daire No:5
<div><span class="tooltiptext"></span></div>
</td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="green tooltip">Daire No:6
<div><span class="tooltiptext"></span></div>
</td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="green tooltip">Daire No:7
<div><span class="tooltiptext"></span></div>
</td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="green tooltip">Daire No:8
<div><span class="tooltiptext"></span></div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="vertical-align: middle; min-width: 50px !important; font-weight: bold;">KAT 3 </td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="green tooltip">Daire No:9
<div><span class="tooltiptext"></span></div>
</td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="green tooltip">Daire No:10
<div><span class="tooltiptext"></span></div>
</td>
</tr>
</tbody>
</table>
</td>
<td>
<table>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="green tooltip">Daire No:11
<div><span class="tooltiptext"></span></div>
</td>
</tr>
</table>
</td>
<td>
<table>
<tbody>
<tr>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td class="green tooltip">Daire No:12
<div><span class="tooltiptext"></span></div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>

Adjust spacing between HTML table rows

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>

align button html emails

i'm creating a very basic html email layout, an one column layout:
this is the layout skeleton:
<html>
<head>
<body>
<table class="outer">
<tr> <!-- structure of a single row-->
<td class="one column">
<table>
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr> <!--END of a row-->
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
</table>
</body>
</head>
</html>
in one row i have a button, its width is 100%:
<tr>
<td class="one-column">
<table width="100%">
<tr>
<td align="center" bgcolor="#cc9435" style="-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0px;" ><a href="#" target="_blank" style="font-size:16px;font-family:sans-serif, Helvetica, Arial;color:#ffffff;text-decoration:none;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding-top:12px;padding-bottom:12px;padding-right:18px;padding-left:18px;border-width:1px;border-style:solid;border-color:#cc9435;display:inline-block;" >button</a></td>
</tr>
<tr>
<td class="spacer">
</td>
</tr>
</table>
</td>
</tr>
css:
/* One column layout */
.one-column .contents {
text-align: center;
}
.one-column p {
Margin-bottom: 10px;
}
.outer {
Margin: 0 auto;
width: 100%;
max-width: 600px;
background-color: #ffffff
}
the button cover the entire width of the template, how can i make it smaller and centered? with on td in a row seems not quite possible, i try with setting margin but obviously doesnt work
thanks
The issues I found in the code are.
There is no need to capitalize CSS classes. Not an issue but just stating!
Since you are setting the background-color for the td element (bgcolor="#cc9435"), it seemed like the button was taking the full width of the table. I moved the background to the a tag alone using the background-color CSS property.
I have reduced the padding property to one line padding:12px 18px where 12px is for the top and bottom padding and 18px is for the left and right padding, you need to increase the left and right padding to see and increase in the width of the button.
Let me know if this fixes your issue!
.td-style {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
padding-top: 0;
padding-bottom: 0;
padding-right: 0;
padding-left: 0px;
}
.a-style {
font-size: 16px;
font-family: sans-serif, Helvetica, Arial;
color: #ffffff;
text-decoration: none;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
padding: 12px 18px;
border-style: solid;
border-color: #cc9435;
display: inline-block;
background-color: #cc9435;
}
.one-column .contents {
text-align: center;
}
.one-column p {
margin-bottom: 10px;
}
.outer {
margin: 0 auto;
width: 100%;
max-width: 600px;
background-color: #ffffff
}
<html>
<head>
<body>
<table class="outer">
<tr>
<!-- structure of a single row-->
<td class="one column">
<table>
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
<!--END of a row-->
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr>
<td class="one-column">
<table width="100%">
<tr>
<td align="center" style="td-style">
button
</td>
</tr>
<tr>
<td class="spacer">
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</head>
</html>
Add width and bg color only to a tag
<td align="center" style="-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0px;">button</td>
Before update
https://jsfiddle.net/17oj738e
After Update
https://jsfiddle.net/17oj738e/1/

Unable To Apply CSS To Table Cell

I have table cells with class=image to which I cannot seem to apply any CSS. Here is my markup (nested tables) where the first table shows an example of a typical row:
<table class="outer">
<tr>
<td>
<table class="column" id="leftColumn">
<tr>
<td>
<table class="cell" id="t1">
<tr>
<td><asp:Literal runat="server" ID="t1r2c1" /></td>
<td class="image">
<span id="s1" runat="server">
<asp:PlaceHolder ID="p1" runat="server">
</asp:PlaceHolder>
</span>
</td>
<td><asp:Literal runat="server" ID="t1r2c3" /></td>
<td class="gray"><asp:Literal runat="server" ID="t1r2c4" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="cell" id="t2">
</table>
</td>
</tr>
</table>
</td>
<td>
<table class="column" id="rightColumn">
<tr>
<td>
<table class="cell" id="t3">
</table>
</td>
</tr>
<tr>
<td>
<table class="cell" id="t4">
</table>
</td>
</tr>
<tr>
<td>
<table class="cell" id="t5">
</table>
</td>
</tr>
<tr>
<td>
<table class="cell" id="t6">
</table>
</td>
</tr>
<tr>
<td>
<table class="cell" id="t7">
</table>
</td>
</tr>
<tr>
<td>
<table class="cell" id="t8">
</table>
</td>
</tr>
<tr>
<td>
<table class="messages" id="t9">
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
Here is my CSS:
.outer
{
border: none;
margin-left: auto;
margin-right: auto;
}
.outer td
{
vertical-align: top;
}
.column
{
border: none;
}
#rightColumn table, #leftColumn table
{
width: 100%;
}
.cell
{
border-collapse: collapse;
border: 2px solid black;
margin: 5px;
}
.cell td
{
border-collapse: collapse;
border: 2px solid black;
text-align: center;
vertical-align: middle;
padding-left: 3px;
padding-right: 3px;
padding-top: 0px;
padding-bottom: 0px;
font-size: 11pt;
}
.cell .image
{
padding: 0;
margin: 0;
height: 2px;
width: 7px;
}
.messages td
{
border-collapse: collapse;
border: 2px solid #FF0000;
text-align: left;
}
h1
{
text-align: center;
font-size: 150%;
}
h2
{
text-align: center;
}
th
{
height: 24px;
background-color: #2B60DE;
color: #FFFFFF;
}
.gray
{
background-color: #AAAAAA;
}
Nothing I do to .cell .image seems to be able to shrink the images below a certain size -- which is already much smaller than the actual images so I know some shrinking is already going on.
Any advice is appreciated.
Could be the line-height or font-size preventing the td to become smaller.
Try setting the tds of the row with the image to line-height: 0px and font-size: 0px
I put together a jsfiddle of your example at http://jsfiddle.net/9xLqY/. The styles are being applied just fine when I remove the ASP components:
<span id="s1" runat="server">
<asp:PlaceHolder ID="p1" runat="server"></asp:PlaceHolder>
</span>
So it must be one of these components that is forcing the cells to be larger than you want. You'll need to add styles for #s1 and #p1.