Two child tables side-by-side in one cell with same height - html

I have two tables next to each other contained in a parent table's cell.
Is there any way (or trick one could use) to make both child tables fit the height of the parent cell with HTML and CSS?
So if a cell has more content than the other, they both would have the same height.
<table cellpadding="0" border="1" cellspacing="0" style="border:none; border:thin solid black; width:600px;" align="center">
<tr>
<td>
<!--left table-->
<table cellpadding="0" border="0" cellspacing="0" style="width:86px; height:100%; background-color:#808080; margin-left:0px;" align="left">
<tr>
<td cellpadding="0" cellspacing="0" border="0" style="background-color:#808080; color:white;" align="center">
Fit the height of the right side?
</td>
</tr>
</table>
<!--right table-->
<table cellpadding="4" border="0" cellspacing="0" style="width:500px; height:100%;">
<tr>
<td align="left" height="42" valign="middle" cellspacing="0" border="0" style="background-color:#000000; padding-left:10px; color:white;">
Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here
</td>
</tr>
</table>
</td>
</tr>
</table>

It's not possible to set a table height to 100% unless the parent has a fixed height (probably not what you want).
Therefore, I'd split that parent TD into two TDs with the desired background colors
<table cellpadding="0" border="1" cellspacing="0" style="border:none; border:1px solid black; width:600px;" align="center">
<tr>
<td style="vertical-align:top; background: #808080; color:white; width:86px;">
<table cellpadding="4" cellspacing="0" border="0">
<tr>
<td align="center">
Fit the height of the right side?
</td>
</tr>
</table>
</td>
<td style="vertical-align:top; background: #000000; color:white; padding-left:10px;">
<table cellpadding="4" cellspacing="0" border="0">
<tr>
<td align="left">
Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here Some text goes here
</td>
</tr>
</table>
</td>
</tr>
</table>

Related

How to horizontally align css table elements?

Trying to replicate this sort of design/structure:
Notice Below the two boxes on one side of the table and the one big one on the other!
How would I achieve this using table css? Here's my current code, which is vertically stacked:
<body>
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="bodyTable">
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="20" cellspacing="0" width="600" id="emailContainer">
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="20" cellspacing="0" width="100%" id="emailHeader">
<tr>
<td align="center" valign="top">
This is where my body content goes.
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="20" cellspacing="0" width="100%" id="emailBody">
<tr>
<td align="center" valign="top">
This is where my body content goes.
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="20" cellspacing="0" width="100%" id="emailFooter">
<tr>
<td align="center" valign="top">
This is where my body content goes.
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
Any idea?:
Steven is right, in theory:
the “correct” way to center a table using CSS. Conforming browsers ought to center tables if the left and right margins are equal. The simplest way to accomplish this is to set the left and right margins to “auto.” Thus, one might write in a style sheet:
table
{
margin-left: auto;
margin-right: auto;
}
But the article mentioned in the beginning of this answer gives you all the other way to center a table.
An elegant css cross-browser solution:
This works in both MSIE 6 (Quirks and Standards), Mozilla, Opera and even Netscape 4.x without setting any explicit widths:
div.centered
{
text-align: center;
}
div.centered table
{
margin: 0 auto;
text-align: left;
}
<div class="centered">
<table>
…
</table>
</div>
See this post
edit thats center this is horizontal just change the neccecery css or see here!

How can i achieve img coming out from border. email templates?

http://imgur.com/a/fKv2H
I need banner with height 100px. and img inside it with height 120px. So the picture comeee out my banner for 20px;
Its for emails.
Also i need text column right before picture, so that text in column with background f4f4f4
<table>
<tr>
<td>
<img src="" style="margin-top:-20px;" />
</td>
<td>
banner text here
</td>
</tr>
</table>
You can do this two ways, one involved slicing the image into two and the other is using two more tables. I have added the code below for you to decide which one you want to go with.
Option 1:
This option has the image as one piece sitting in an outer table with 3 columns. The outer two columns have a table with white background to cater for the heads/hats popping out of the grey area. I have set the table width at 100% to show it will look.
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" bgcolor="#f4f4f4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#ffffff" style="height: 23px;" height="23"></td>
</tr>
</tbody>
</table>
</td>
<td width="171" valign="top"><img src="http://i67.tinypic.com/sdk1hh.jpg" width="171" height="178" style="display: block;"></td>
<td valign="top" bgcolor="#f4f4f4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#ffffff" style="height: 23px;" height="23"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Option 2
For this option, you will need to slice the top part of the image (with white background) and place both the images in one table with two rows. Both images are centered and I have set the table width at 100% to show it will look.
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" valign="top" bgcolor="#ffffff"><img src="http://i64.tinypic.com/lz7f6.png" style="display: block;">
</td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#f4f4f4"><img src="http://i68.tinypic.com/4qo1mu.png" style="display: block;"></td>
</tr>
</tbody>
</table>
The final outcome for both codes should look like this:
Let me know which option best suits you.
** UPDATE **
Your question asked if you can have option 1 with image to the left and text on the right, here is the example:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="171" valign="top" style="padding-left:20px;"><img src="http://i67.tinypic.com/sdk1hh.jpg" width="171" height="178" style="display: block;"></td>
<td valign="top" bgcolor="#f4f4f4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#ffffff" style="height: 23px;" height="23"></td>
</tr>
<tr>
<td style="font-family:Arial; font-size:12px; color:#000000; padding:5px 10px;">This is some text for your email</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
I added colors so you could see that it was outside the table. I gave the image a height of 120px, width of auto. Made the td's have a max-height of 100px; And I left your -20px margin on the image.
<body style="background-color:pink">
<table style="background-color:orange;">
<tr>
<td style="max-height:100px; overflow-y:initial;">
<img src="https://i.imgur.com/ZESO4DT.png" style="margin-top:-20px; height:120px; width:auto;" />
</td>
<td style="max-height:100px;overflow-y:initial;">
banner text here
</td>
</tr>
</table>
</body>

Moving tables and its content to the top and bottom of a bigger cell

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;
}

Table row on top of columns

The text I have on top in the table row is somehow affected by the second column below it..cant seem to have it take up the entire width of the table.
http://jsfiddle.net/PmWBw/2/
Sorry I know I am the only one still working in tables. HTML emails still exist.
<table width="800" class="bodyContent" style="border: 1px solid #b8b7b7;margin-bottom: 20px;">
<table>
<tr style="width: 800px;">TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT</tr>
</table>
<td valign="top" width="260" class="leftColumnContent">
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_left.png" mc:label="image" mc:edit="tiwc300_image00" />
</td>
</tr>
</table>
</td>
<td valign="top" width="260" class="rightColumnContent">
<!-- // Begin Module: Top Image with Content \\ -->
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_right.png" mc:label="image" mc:edit="tiwc300_image01" />
</td>
</tr>
</table>
</td>
</table>
For starters, your first row consists of a td inside a tr that's inside ANOTHER td. If nothing else, that should probably be addressed.
Also, a bit unrelated to you original question, but it seems a bit redundant to have tables inside of your cells, when I'm not seeing any real benefit or function gained by the added code. You're styling your inner tables with the same things you can be applying to either the td or the image itself. At least in this particular application.
Just a thought.
UPDATED:
<table width="600" class="bodyContent" style="border: 1px solid #b8b7b7;margin-bottom: 20px;">
<tr>
<td colspan="2">
<table>
<tr style="width: 600px;">
<td>TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT TEST TEXT</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="260" class="leftColumnContent">
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_left.png" mc:label="image" mc:edit="tiwc300_image00" />
</td>
</tr>
</table>
</td>
<td valign="top" width="260" class="rightColumnContent">
<!-- // Begin Module: Top Image with Content \\ -->
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tr mc:repeatable>
<td valign="top">
<img src="http://www.homeplan.com/newsletter/images/top_right.png" mc:label="image" mc:edit="tiwc300_image01" />
</td>
</tr>
</table>
</td>
</tr>
</table>
First of all, you can not have the code looking like this:<td><tr><td>asdf</td></tr></td>. It the <tr> needs to be wrapped by <table>.

html float bottom

I want to make text float to the very bottom right hand corner of an existing tag.
I'm still using old school tables (editing existing code). My code is this:
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="50%"></td>
<td width="50%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" valign="top">KEEP UP TOP</td>
</tr>
</table>FLOAT BOTTOM
</td>
</tr>
</table>
The text that says FLOAT BOTTOM, doesnt obviously. How do make it so that always stays at the very bottom right corner?
The usual way to do this with tables is
Create a second row
Give that row (and the cells therein) a fixed height
Put the text into the right hand column in the second row
One CSS way to do this (without tables) would be
Give the container you want to place the text in the bottom right corner of position: relative
Wrap the text inside a <span>
Give the span position: absolute; bottom: 0px; right: 0px
Use style {style="vertical-align:baseline; text-align:right"}
Try this:
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="50%"></td>
<td width="50%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" valign="top">KEEP UP TOP</td>
</tr>
</table><p style="position:absolute; bottom:0px; right:0px;">FLOAT BOTTOM</p>
</td>
</tr>
</table>
To make it float to the bottom right of the data cell that contains it you could probably do
<span style="float:right; vertical-align:text-bottom">FLOAT BOTTOM</span>