Why doesn't overflow:hidden work on a td? - html

I have a table and the overflow: hidden property doesn't work, why is that?
<table width="100%" style="table-layout:fixed">
<tr height="200">
<td width="100%" height="200" valign="middle" style="text-align: center; overflow: hidden;">
<img src="http://salesdey.com/product_images/eb235de7eee13a0aa61dae2cc9de1f7e.gif" width="100" />
</td>
</tr>
</table>

According to w3schools :
The overflow property only works for block elements with a specified height.
Since <div> is a block element you can try to use that in your <td> cell and then apply the property on it.
Also, as commented by #Roberrt this is already answered here in detail.
Why does overflow:hidden not work in a <td>?

Because the contents of a cell never overflow the cell in the Y direction. The cell height will always grow vertically to contain its contents. So there's nothing for the overflow property to do.

overflow:hidden not work on table-cell, if you can change the html, you should use a div instead of table.
But if you can do it... Then you should add display:inline-block to the td.

Related

Overlapping tables / negative top position in HTML email

Is there an alternative to negative positioning in HTML emails? The image in the second table below is positioned 100px up using negative positioning. I need that image to overlap somewhat with the content above.
<table>
<tr>
<td valign="top" width="400" style="padding-right:10px;">
<p style="color:#575757;font-size:13px;line-height:19px;font-weight:normal;font-family:'Century Gothic'; text-align:justify;">Lorem Impsum</p>
</td>
<td><img src="kneeler.jpg" /></td>
</tr>
</table>
<table>
<tr>
<td style="position:relative; top:-100px;"><img src="shoes.jpg" /></td>
<td valign="top" width="400" style="padding-left:10px;">
<p style="color:#575757;font-size:13px;line-height:19px;font-weight:normal;font-family:'Century Gothic'; text-align:justify;">Lorem ipsum</p>
</td>
</tr>
</table>
I've tried padding-top: -100px; but that did not work. Please help!
You can do this by wrapping the element above in a div and setting the height of the wrapper to be less than the actual height of the element. (for example, height:200px if the element is naturally 300px and you want 100px of overlap) The element will overflow the wrapper, but the next element will start where the wrapper ends.
See answer here:How to position an element on top of another element without using position and margin?
And the example:
https://jsfiddle.net/acq3ob6y/1/
Negative values are mostly unsupported in html email. So is CSS position. For webmail at least, this is so that your email doesn't render outside of the desired window. Imagine Gmail with your CSS or email affecting the interface - they've limited the CSS you can use specifically to prevent this.
The only way to accomplish an image overlapping the container is to fake it. See this similar question for an example

Overflow-x scroll not working in tr

I have a Table that contain a tr in this tr there is several td i need to have overflow-x scroll but it isn't working.
<tr id="TR_TESTS_BY_CAT" width="100%" height="480px" style="display: none; overflow-x:scroll">
<td height="530px" valign="top" id="TD_TESTS1" style="width: 25%">
<div id="divTests1" style="height: 530px; width: 100%; vertical-align: top;">
</div>
</td>
<td>.....</td>
.....
but it isn't working
overflow is not applicable to <TR>s by definition. TR (display:table-row) is not a block element - does not establish box (remember col/rowspans in cells).
Only block-alike elements (display:block | inline-block | list-item) have concept of overflow as they have box were to scroll.
You can give your td specific sizes: width:200px; this will set the size and the div should also get a width equal or lower, so the there wont be a horizontal scroll.
This is a work around obviously. if you want to get the best solution you can switch to using <div> instead of tables and and avoiding inline css. You can only imagine how much more you can do with css styling.

Html table width

I have code like this:
<table width="625px">
<tr style="background-color:#CCC; font-size:14px;">
<td style="padding:8px; color:#333"><center><?=stripslashes($arr['signature']);?> </center></td>
</tr>
If $arr['signature'] is a long string, like this gjuytfdcrtrfdscvythgfvtfdgtrfdvbgfvcfgbdc the width doesn't help and it goes very wide. How can I prevent that?
there are many ways, depends on what you wish to do.
If you apply overflow:hidden then the overflown text would be hidden. You can use overflow:scroll; inside a div like <td style="padding:8px; color:#333"><center><div style="overflow:scroll; width:625px;"><?=stripslashes($arr['signature']);?></div> </center></td>
This will create a scroll for the overflow text, only for this cell (there is need to give width for this method).
Here an example for the overflow:scroll;
Try:
<td style="width: 160px; max-width: 160px;">
or
<td style="width: 160px; overflow-x: hidden;">
or both together.
See
http://www.highdots.com/forums/html/limit-width-table-cell-271764.html
Use the overflow property:
<table width="625px" style="overfow: hidden;">
use the overflow style property on the "td" tag
<td style="overflow-x: hidden;">your text here</td>
See the section on table widths in the CSS2 spec: http://www.w3.org/TR/CSS2/tables.html#width-layout
Roughly, tables will choose the maximum of the specified width and the sum of the widths of their columns. You have to constrain the width of the column, perhaps by setting a width on the element (you'll want to choose your overflow style here as well).
Example:
<table width="625px">
<tr style="background-color:#CCC; font-size:14px;">
<td style="padding:8px; color:#333; width: 625px; overflow: hidden; text-align:center"><?=stripslashes($arr['signature']);?></td>
</tr>
</table>
(Also note that <center> has been long deprecated; please use the text-align CSS property.)
I remember spending hours on that. Use the table-layout:fixed style.
<table style="width:625px;table-layout:fixed;overflow:hidden">
Each column will take the size of its first cell.

display: table-cell; in ie6/7 workaround

I'm trying to build a single row css table with multiple cells that has text that is vertically centered inside the cells. Basically the table behaviour I am trying to mimic with css is this:
<table width="100%" height="54" border="0" bgcolor="red">
<tr>
<td width="20%">text</td>
<td width="20%">text</td>
<td width="20%">text</td>
<td width="20%">text</td>
<td width="20%">text</td>
</tr>
</table>
So that my code is semantically correct I want to use divs to achieve the same effect.
<div class="job_wrapper">
<div class="info">
<div>01</div>
<div>Campaign 001</div>
<div>DEMO Client</div>
<div>128</div>
<div>449</div>
</div>
</div>
Problem is that the workaround for display:table-cell in IE involved using the float property which overrides the display value to block. hence I lose the vertical centering of text in a table cell.
Is there a workaround to display:table-cell in IE that still gives me the ability to center text vertically in IE?
Cheers
check out the style sheet from http://jogger.pl/404.
they have an interesting workaround in there.

Not able to move DIV around

I have the following code:
<textarea>
<td align="center" bgcolor="#996633" onMouseover=javascript:ShowContent("menu7_items") onMouseout=javascript:HideContent("menu7_items")>
<p> Stock Update </p>
<div id="menu7_items" style="display:none;" onMouseover=javascript:ShowContent("menu7_items") onMouseout=javascript:HideContent("menu7_items")>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left">Update Paper</td>
</tr>
</table>
</div>
</td>
</textarea>
There is a TD inside which there is a DIV and inside DIV there is a Table. DIV's default style is display:none. On mouseover TD, the div should appear like a popup in a given position. But it is not happening. DIV is appearing in the same TD. How to make DIV's position independent of TD.
position: absolute;
You may also want to specify the direction properties (top, right, bottom, left), but try it without those first to see how it looks. If you use them, you may want to use position: relative on the parent to position the absolute child relative to it (the same works with any position value that isn't "static", the default).