Below is my code for 2x tables. There is PHP & results I have removed. But I cannot get these on one line but next to each other.
I have tried Align Left/Right and this puts them on 2x separate lines? I have tried float as well and this has not helped either.
Does anybody have advice for me?
HTML
<table width="40%" border="0" cellpadding="0" cellspacing="2" class="table">
<tr align="center">
<td colspan="16" class="header"><center>Last 5 Received Transactions</center></td>
</tr>
<tr align="center">
<td class="header"><center>Transaction ID</center></td>
<td class="header"><center>Sent To</center></td>
<td class="header"><center>Amount</center></td>
<td class="header"><center>Date</center></td>
</tr>
</table>
<table width="40%" border="0" cellpadding="0" cellspacing="2" class="table">
<tr align="center">
<td colspan="16" class="header"><center>Last 5 Sent Transactions</center></td>
</tr>
<tr align="center">
<td class="header"><center>Transaction ID</center></td>
<td class="header"><center>Sent By</center></td>
<td class="header"><center>Amount</center></td>
<td class="header"><center>Date</center></td>
</tr>
</table>
CSS :
table
{
border: #000000 1px solid;
background-color: #363636;
}
You could also add a class of left and right to each table and define floats in your css if you want the tables to always align left and right.
table.left {
float: left;
}
table.right {
float: right;
}
<table width="40%" border="0" cellpadding="0" cellspacing="2" class="left">
YOUR LEFT TABLE content
</table>
<table width="40%" border="0" cellpadding="0" cellspacing="2" class="right">
YOUR RIGHT TABLE content
</table>
You don't need the 'table' class because you can use the table tag as a selector.
Try adding display:inline-block;
Update CSS
table
{
border: #000000 1px solid;
background-color: #363636;
display:inline-block;
}
WORKING:DEMO
Float doesn't work on display: table which is the default table display property.
You have to put display: block on it in order to float them
table {
border: 1px solid #000;
display: block;
float: left;
width: 40%;
}
table:first-child {
margin-right: 40px;
}
Working Fiddle
Related
I am trying to change the position of the text to the TOP of the center. I am using table which i need to use in email template.
Here is my fiddle
https://jsfiddle.net/g2sbhf7k/
<td height="1"><p>hello</p><p>hello</p> </td>
this is showing in middle left, but i need to show in top center
Thanks
See if this helps
<td style="vertical-align: top; text-align: center;" height="1">
<p>hello</p>
<p>hello</p>
</td>
Using all the rest of your code, I just added a class
html:
<td height="1" class="topCenter"><p>hello</p><p>hello</p> </td>
css:
.topCenter{
text-align: center;
vertical-align: top;
}
Your answer is here .... though I've shorten some code:
https://jsfiddle.net/SAS3000/tx6zfgba/
table table {
width: 191px;
background-color: #ffffff;
border-radius: 4px;
box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.08);
border: 1px solid #ddd;
}
td {
text-align:center;
vertical-align:top;
}
<table border="0" cellpadding="0" cellspacing="0" style="margin:0 auto;width:600px;background-color: #ffffff;">
<tr>
<td align="left">
<table height="180px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="1">
<p>hello</p>
<p>hello</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
This can be done at table level without CSS as well.
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" valign="top">centered text</td>
</tr>
</tbody>
</table>
Is it possible to vertically align table 3 at the bottom in the following example?
This is for a mail signature, hence the use of tables and the hack with align to make the tables responsive (they'll stack underneath each other if viewport gets too small). Now, the client wants the logo in table 3 to be aligned at the bottom (see example image) and I'm beginning to wonder if this is even possible while keeping it mobile friendly.
I've tried vertical-alignment: bottom pretty much everywhere and margin-top: auto; margin-bottom: 0; on table 3 to no avail. I'm guessing the align="left" overrides pretty much ever vertical alignment styling I'm trying to make.
<table align="left" border="0" cellpadding="0" cellspacing="0" style="border: 1px #000 solid; max-width: 903px; width: 100%">
<tr>
<td>
<!-- "responsive" tables -->
<!-- table 1 -->
<table align="left" border="0" cellpadding="0" cellspacing="0" style="border: 1px #ff0000 solid; width: 300px;">
<tr>
<td>
Company logo
</td>
</tr>
</table>
<!-- table 2 -->
<table align="left" border="0" cellpadding="0" cellspacing="0" style="border: 1px #00ff00 solid; width: 300px;">
<tr>
<td>
Contact details<br>
<br>
<br>
</td>
</tr>
</table>
<!-- table 3 -->
<table align="left" border="0" cellpadding="0" cellspacing="0" style="border: 1px #0000ff solid; width: 300px;">
<tr>
<td>
Another logo
</td>
</tr>
</table>
</td>
</tr>
</table>
You could use a vertical-align and give the cell a height using CSS.
#media (min-width: 1000px) {
.logoHolder td {
height: 50px;
vertical-align: bottom;
}}
<table align="left" border="0" cellpadding="0" cellspacing="0" style="border: 1px #000 solid; max-width: 903px; width: 100%">
<tr>
<td>
<!-- "responsive" tables -->
<!-- table 1 -->
<table align="left" border="0" cellpadding="0" cellspacing="0" style="border: 1px #ff0000 solid; width: 300px;">
<tr>
<td>
Company logo
</td>
</tr>
</table>
<!-- table 2 -->
<table align="left" border="0" cellpadding="0" cellspacing="0" style="border: 1px #00ff00 solid; width: 300px;">
<tr>
<td>
Contact details<br>
<br>
<br>
</td>
</tr>
</table>
<!-- table 3 -->
<table class="logoHolder" align="left" border="0" cellpadding="0" cellspacing="0" style="border: 1px #0000ff solid; width: 300px;vertical-align: bottom;">
<tr>
<td style="vertical-align: bottom;">
Another logo
</td>
</tr>
</table>
</td>
</tr>
</table>
I have a screenshot as shown below which I have to replicate in html/css.
Attached is the fiddle for the above screenshot which I am able replicate at this moment.
Problem Statement:
I am wondering what changes I need to make in the inline styles in the fiddle so that I am able to limit the length of a border. At this moment, it is covering the full screen.
The snippets of code which I have used in order to achieve the above screenshot are:
<tr>
<td style="text-align:left;padding-left:10%;padding-bottom:1%;">poster: donald duck</td>
<td style="text-align:center;;padding-left:10%;padding-bottom:1%;">customer: donald duck</td>
</tr>
Based on the code you gave in the fiddle,you set the width attribute in the table tag width="100%", try set it to whatever value you want.
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="font-size:
20px;
...
">
to
<table cellpadding="0" cellspacing="0" border="0" width="600" style="font-size:
20px;
...
">
You can try doing this.
You need to add margin: 0 auto; to align it to center
Set the width of the table so it will have a limit and will not occupy the whole screen.
Please see the code below.
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0" width="50%" style="
margin: 0 auto;
font-size: 20px;
border-bottom: 2px solid #484848;
border-top: 2px solid #484848;
padding-top: 2%;
padding-bottom: 2%;
padding-left: 5%;
padding-right: 5%;
">
<tr>
<td style="text-align:left;padding-bottom:1%;">poster: donald duck</td>
<td style="text-align:left;padding-bottom:1%;padding-left: 10%;">customer: donald duck</td>
</tr>
<tr>
<td style="text-align:left;padding-bottom:1%;">phone: 613-613-6134</td>
<td style="text-align:left;padding-bottom:1%;padding-left: 10%;">phone: 613-613-6134</td>
</tr>
<tr>
<td style="text-align:left;padding-bottom:1%;">email: dduck#gmail.com</td>
<td style="text-align:left;padding-bottom:1%;padding-left: 10%;">email: dduck#gmail.com</td>
</tr>
</table>
</td>
</tr>
I'm currently building an email signature, a simple 4 images sectioned off in a square 2x2 table.
The problem I'm currently facing is I can't remove the spacing between the td's at the moment.
<style>
d, tr, img { padding: 0px; margin: 0px; border: none; display: block; }
table { border-collapse: collapse; }
</style>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<img src="http://bubblei.co.uk/NDz2UL.png" ></img>
</td>
<td>
<img src="http://bubblei.co.uk/BMSIqd.png"></img>
</td>
</tr>
<td>
<img src="http://bubblei.co.uk/VcOrDE.png" ></img>
</td>
<td>
<img src="http://bubblei.co.uk/DlwKjq.png"></img>
</td>
</tr>
</table>
Can anyone tell me where I'm going wrong, or point me in the right direction? much appreciated!
Your images all have different size. I've taken the liberty to smoothly change one of them, and the result is already way better. You should align them and honer the same dimensions on all images.
<style>
d, tr, img { padding: 0px; margin: 0px; border: none; display: block; }
table { border-collapse: collapse; }
</style>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<img src="http://i.imgur.com/tBrf7Fu.png" >
</td>
<td>
<img src="http://bubblei.co.uk/BMSIqd.png">
</td>
</tr>
<td>
<img src="http://bubblei.co.uk/VcOrDE.png" >
</td>
<td>
<img src="http://bubblei.co.uk/DlwKjq.png">
</td>
</tr>
</table>
How can I move the rows titled "border one" and "border two" to the top and bottom of the cell they reside in? If I try padding top/bottom, it messes up the structure upon zooming in/out.
Here's a fiddle: http://jsfiddle.net/0uzjyxa5/
<table align="center" border="1" cellpadding="0" cellspacing="0" width="680" height="942" style="border-top: 1px solid white;">
<td style="width: 288px; height:auto;">
</td>
<td>
<table border="1" width="100%">
<tr><td>border top</td></tr>
</table>
<table border="1" width="100%">
<tr><td>venue info</td></tr>
</table>
<table border="1" width="100%">
<tr><td>border bottom</td></tr>
</table>
<td style="width:17px;"></td>
</td>
</table>
You can align your table data using
table td {
vertical-align: bottom;
}
or
table td {
vertical-align: top;
}