Most of the elements on my email page will line up on all email clients correctly if I give the tr and td correct height / widths and tr display inline-block. However on a certain block im having troubles getting the elements to line up without a gap / space between elements.
The first image is the rounded corners on the left and I got it to line up with the block next to it by giving the td / tr and smaller width than that of the img thats inside. However I cannot do this to the other blocks or else they just get smaller all together.
I can change my structure if needed but right now I've kinda limited myself by putting all elements as td's in one tr instead of each element being a tr
<tr>
<td>
<img left corners />
</td>
<td>
180
</td>
<td>
22
</td>
<td>
<img right corners />
</td>
</tr>
fiddle away! http://jsfiddle.net/Qh7En/1/
Thanks!
Here you go. :)
I basically altered the display property.
http://jsfiddle.net/Qh7En/7/
Also, it would probably be better if you didn't use inline CSS. Consider making a class instead.
Are you seeing this in all browsers?
It looks like a typical issue with images always having padding, unless you specifically tell CSS to remove it. Something as simple as adding "img { padding:0px }" to the CSS.
Several ways to fix this.
One is to comment out the white space between the elements.
.....
</td><!--
--><td
....
Demo http://jsfiddle.net/Qh7En/8/
Related
I'm having trouble with the layout of one of my pages (http://jsfiddle.net/NeonGuilmon/pghtZ/5/)
I'm trying to create the interface of a chatroom, with the section room in the top-left of the screen, (100% - 200px) in width and height, section users in the top-left, 50% height and 200px width, section friends in the bottom left with the same dimensions ad users, and chat-bar in the bottom right, 200px in height and (100% - 200px) in width.
As you can see from my fiddle, I messed up pretty badly, and I have no idea where to go next. Can anyone help me with this?
I really recommend reading the following two links:
http://www.w3.org/TR/CSS2/visuren.html
http://www.w3.org/TR/CSS2/box.html
Correctly understanding how position/display work and the difference between margin/ etc is key.
You are currently working with display:block. This basically means that each element will be placed under the next one.
You are using right-margin. This will force a white margin on the right of the element and will not allow anything to sit in that space
Finally if you want to align 4 block elements side by side using a table can ease a lot of the problem (don't go overboard with tables though).
So the easiest way to set something like this up: (I placed the layout on the html but you can put it in the css. Also remove all the positioning and height hints you currently have on your sections. they should just take all the space they can inside the table cell
<table height="100%" border=1>
<tr height=50%>
<td width=100%><section id="room">room</section></td>
<td width=200px><section id="users">users</section></td>
</tr>
<tr height=50%>
<td><section id="friends">friends</section></td>
<td><section id="chat-bar">chatbar</section></td>
</tr>
</table>
Solved my problem: I didn't realize CSS calc was so widely supported: http://caniuse.com/#search=calc
fiddle - here you got 2 exacly same styled tables. TD's width is auto adjusted by table-layout. It works ok, when there is only one line of text. But when there is more text and text is warped it seems like width is calculated by all the text (like it was in one line), not by the longest warped part of text.
Question is how to center content of table nr 2 the same way as it is done in 1'st table? (atm it dont look like centered at all...)
- this is how it should look (lower one) - dont needed yellow space should be cutted to allow table to be centered.
td { text-align:center }
The text in the first table isn't actually centered. It just appears that way because it has no breathing room on either side of the cell.
Making a global declaration like the above would allow additional tweaks to remaining cells.
td.first { text-align:left; font-weight:700 }, etc.
EDIT
You're not going to be able to achieve that effect without declaring a width. Tables don't act like divs by default, so I gave it display:block, width:80% and now the tables center, the td wasn't filling its parent correctly, so I gave it width:100%.
I think this is what you're after: http://jsfiddle.net/hJXb9/
I think you are looking for this.
<table style="width:60%;margin-left:20%;margin-right:20%;">
<tr>
<td style="background:green;text-align: center; vertical-align: middle;">
TADA
</td>
<td style="background:yellow;text-align:center; vertical-align: middle;">
Lorem ipsum dolorsitamet kjfldslggfh;l</td>
</tr>
</table>
Live Demo
Hope, i will helps you. Thanks. !!
I had this newsletter http://jsfiddle.net/n5cGm/
with a container div to center the newsletter and to give it a background image,
OK, we experienced few problems with it when sending it, it changed from (browser)
to (Outlook): check the logo position; don't even bother the border radius. is only there for the browsers that support it; not important if not.
And this is the second (wrong for now) version I am trying with a table inside a table:
http://jsfiddle.net/9dchU/1/
which in Firefox works fine but embedded in jsfiddle not and in Outlook looks almost the same...
can you see the style that is messing the padding?
As some browsers, some e-mail clients neither able to display the border-radius parameter. I suggest, use image for the white background.
I would start over from scratch. You seem to have a tag that's either not closed, extra or useless. Let me explain, there is no point in using the tbody or th tags for emails. They cause rifts in designs every time I test. Your design is actually really simple. What you want to do is something like this:
<table cellpadding="0" cellspacing="0" border="0" style="font: Arial;">
<tr><td>
<img src="http://domain.com/top-image.gif" />
</td></tr>
<tr><td bgcolor="#ffffff" style="padding: 20px">
text text text
</td></tr>
<tr><td>
<img src="http://domain.com/bottom-image.gif" />
</td></tr>
</table>
Don't use background images for emails as they are not supported.
Here's what you do instead:
Take a look at the above picture. Forget about the four corners you're going to crop in in 3 slices horizontally.
The top would be your top-image.gif
mid you can discard, that's where your text should go.
Finally the bottom slice will be your bottom-image.gif
Hope this points you in the right direction.
So I have a table with only two columns and one row. The second td holds an image, and the first holds text. I would like the td containing the image to be at the minimum size possible with that image inside, and the first td to fill the remaining space. The following works in every browser except IE7 (we are not doing IE6):
<table> <tr><td style="width:100%;">TEXT</td><td><img src="jpg" alt="jpg" /></td></tr> </table>
What happens is this:
The page renders correctly, then when you mouse over the table, the first td expands to fill the entire table, pushing the image off the edge.
I could fix this with some jQuery to measure the width of the image and calculate remainder for the first td; but that solution is full of LAME!
Please help. I do not understand why IE7 feels the need to redraw the way it does.
Try the following code instead. Instead of explicitly declaring too much width, try explicitly declaring too little (because the image will push the width beyond 1% anyway.)
I am writing this off the top of my head without actually having looked in IE7, but I have IE7 in a Virtual Machine at home and so I'll comment back later if I find a different solution.
<table style="width: 100%;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>TEXT</td>
<td width="1%" style="width: 1%;"><img src="http://www.google.com/intl/en_com/images/srpr/logo2w.png" alt="Google Logo" /></td>
</tr>
</table>
There are a couple of things that you could try:
Make sure you're using a reset.css stylesheet to reset all of the browser defaults and accommodate any browser quirks. That's especially important with Internet Explorer.
Only use tables for tabular data — I'm not sure what the rest of your table contains, but unless there's going to be rows of data, it would be much easier to use a container div with a p and img floated.
Set the width and height on the img.
Use CSS position: relative; float: left; to see if it helps with positioning issues on hover. I see hover issues a lot with jQuery scripts and browser hacks like CSS3 PIE — if you're using those, try removing them.
Try setting the style="zoom:1" on the element.
I am not sure but looking at
<table> <tr><td style="width:100%;">TEXT</td><td><img src="jpg" alt="jpg" /></td></tr> </table>
from what I can see is that there is no table width on this, so IE does not know how to scale the td appropriately.
Another guess is because you're are declaring width as 100% on the first one IE interprets this to shove it off. Which is my guess, you can not have a width of 100% on the first cell because it means to take up 100% of the full table width.
clear you browser cache, specify a width and height on your image
i have seen the most weird stuff on ie7, like pagebreaks \n and such causing this effect, ie:
<a href="#>
<img src="jpg" />
</a>
to fix just put everything on the same line and without spaces (like your table with a space on the right)
also avoid using inline style, use a stylesheet (css)
I wanted to know if I customize a table with <td> and <tr> elements in the same way I usually customize <div> elements of a page.
I'm asking this because I cannot modify the generated html code, and I would like for example to float the rows to right, or to add padding, margin.
Is CSS working perfectly on <tr> or <td> elements ? (I am asking you this before to start).
thanks
Is CSS working perfectly on or
elements ? (I am asking you this
before to start).
Yes, you can apply css to any element. By the way, you can choose the direction of TDs by specifying align="left" or align="right". No need to float them. You could have provided sample of what you want to achieve though.
It all depends what you want to do. If you want to apply custom floating to particular cells (using CSS float) you might get crazy results because you mock around with box-model of <td> element.
If you want to float the text/content inside, you can always use text-align:left / right / center.
Again - if you want to affect content of the TD it should be relatively same as if you used <div>. If you want to affect td itself you might get unexpected results especially around position, float, z-index, display CSS attributes.
"I am asking you this before to start".
That's a bit stupid (no(t too much) offense) don't you think?
If you had give it a try you would have seen that there's no problem. Just be aware that default style is not the same and that there are some constraint due to the displaying of table element (which you can get rid of by using the css display property).