Given the following for an email template:
<style> @import url("http://fonts.googleapis.com/css?family=Open Sans"); </style> <div style="width:100%; background:#F2F2F2"> <table style="padding: 25px; margin: 0 auto; font-family:'Open Sans', 'Helvetica', 'Arial';"> <tr align="center" style="margin: 0; padding: 0;"> <td> <table style="border-style:solid; border-width:2px; border-color: #c3d2d9;" cellspacing="0"> <tr style="background-color: white;"> <td style="width: 700px; padding: 10px 15px 10px 15px; color: #000000;"> <p>Some content here</p> <span style="font-weight: bold;">My Signature</span><br/> My Title<br/> My Company<br/> </td> </tr> </table> </td> </tr> </table> </div>
The table will be exactly 700px wide is what is needed. However, because its entirely fixed width, it can't resize on devices with less than 700px width. But if I modify the td element to this:
<td style="max-width: 700px; width: 90%; padding: 10px 15px 10px 15px; color: #000000;"> <p>Some content here</p> <span style="font-weight: bold;">My Signature</span><br/> My Title<br/> My Company<br/> </td>
Then the table is only ~100px wide.
How would I reorder the CSS to make it so that the table is 700px but resizes as the viewport grows smaller?
It seems like this should be one of the easiest things to understand in CSS. If you want a block-level element to fill any remaining space inside of its parent, then it's simple — just add width: 100% in your CSS declaration for that element, and your problem is solved.
The best possible solution for this is the one you are using now. Since you cannot predict the number of columns you cannot set a width to each column. So setting the overflow of the parent div to auto and the child table width to 100% is the best solution.
Click inside the table. On the menu, select Table > AutoFit > AutoFit to Window.
"width" is a standard width measurement for defining the exact width of an element. Defining "width:100%" means that the width is 100%. Defining "max-width:100%" means that the width can be anywhere between 0% and 100% but no more then 100%.
You need to use:
table{ width:100%; table-layout: fixed; overflow-wrap: break-word; }
Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With