I am trying to create an Email Signature Generator. I am trying to get the blue line (it can be seen in the program) to stretch all the way down. However, when I do it, it stretches the rest of the items. I believe this may be because it is all inside a table and when one element is sized differently than the others, it tries it equal it out but I am not sure how to change it. Here is my code:
table {
display: inline-block;
}
#image {
width: 200px;
height: 200px;
border-radius: 50%;
}
.spacer {
width: 30px;
}
hr {
height: 200px;
width: 7.5px;
border-radius: 20px;
border: none;
background-color: cornflowerBlue;
}
#fullName {
font-family: 'Source Sans Pro', sans-serif;
font-size: 24px;
color: orange;
}
#job {
font-family: 'Source Sans Pro', sans-serif;
font-size: 16px;
padding-top: 11px;
}
#jobLocationText {
font-family: 'Source Sans Pro', sans-serif;
font-size: 15px;
padding-top: 6px;
}
<table cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;">
<tr>
<td>
<img src="https://vignette2.wikia.nocookie.net/mafiagame/images/2/23/Unknown_Person.png/revision/latest?cb=20151119092211" id="image">
</td>
<td class="spacer"></td>
<td>
<hr>
</td>
<td class="spacer"></td>
</tr>
<tr>
<td>
<center>
<div id="fullName">Billy Staples</div>
</center>
</td>
</tr>
<tr>
<td>
<center>
<div id="job"><i>Programmer</i></div>
</center>
</td>
</tr>
<tr>
<td>
<center>
<div id="jobLocationText">at the <b id="jobLocation">HTML hub</b></div>
</center>
</td>
</tr>
</table>
And a working version can be found here.
Again, I am trying to get it so the hr (in the CSS) when the height is changed (to say 300 or something) it doesn't stretch the rest of the table with it. If you have an idea as to how I might be able to do my table differently so that it might be easier or just so that I could fix this problem, suggestions are welcome!
Thanks in advance!
Use rowspan="" to strech <hr> to way down,
<td rowspan="4">
<hr>
</td>
Here's your updated code, https://jsfiddle.net/he84kv8n/10/
<hr> is a horizontal rule (divider), bending it to be a vertical rule (divider) is a use case that will likely be difficult for anyone looking at your code to decipher.
I would suggest using a CSS border attribute on the table cell, that will automatically be the correct size.
Related
I have built a few email templates the issue is that the CSS is not working on yahoo / outlook / windows native app etc. Pretty much anything that is not mac or google.
I did write the templates using tables but for the CSS I used the style tag because I want the templates to also be responsive.
I will leave some code examples below maybe you can point out my mistake.
<style type="text/css" data-hse-inline-css="true">
* {
margin: 0;
padding: 0;
}
body {
background-color: #ebeff5;
font-family: 'Source Sans Pro', sans-serif;
}
table,
tr,
td {
margin: 0;
padding: 0;
}
table {
border-spacing: 0;
}
img {
width: 100%;
border: 0;
}
p {
font-size: 20px;
color: #39506f;
line-height: 30px;
}
a {
text-decoration: none;
cursor: pointer;
}
.wrapper {
width: 100%;
table-layout: fixed;
background-color: #ebeff5;
}
.main {
background-color: #ebeff5;
margin: 0 auto;
width: 100%;
max-width: 750px;
padding: 35px 15px;
}
.spacing-one {
height: 15px;
}
.spacing-two {
height: 25px;
}
.card {
padding: 20px;
background-color: #ffffff;
border-radius: 5px;
}
.main-font {
font-size: 30px;
color: #1b3040;
font-weight: 400;
}
...
<main class="wrapper">
<table class="main">
<tr>
<td class="card">
<table width="100%">
<tr>
<td>
<img
class="logo"
src="path"
alt="logo"
/>
</td>
</tr>
<tr class="spacing-two"></tr>
<tr>
<td>
<h1 class="main-font">Hey {{name}},</h1>
</td>
</tr>
<tr class="spacing-one"></tr>
<tr>
<td>
<p>text.</p>
</td>
</tr>
<tr class="spacing-one"></tr>
<tr>
<td style="height: 56px">
<a href="{{url}}" target="_blank">
<span class="main-button"
>Reset Password
<img
class="main-button-icon"
src="path"
alt=""
/></span>
</a>
</td>
</tr>
<tr class="spacing-one"></tr>
<tr>
<td>
<p>
text.
</p>
</td>
</tr>
</table>
The biggest issue here is that not all email clients support HTML5 semantics (like the <main> tag you're using). And email clients will behave very differently in how they do not support it. You can refer to Can I email for details on support of HTML5 semantics.
For example, Gmail does not support the <main> tag. But it will change it into a <div> element and apply the same class attribute you had in the first place, making this seamless.
Yahoo, however, will remove the <main> element completely, thus also removing the styles you wanted to apply on it.
In your case, changing <main class="wrapper"> into <div class="wrapper"> is enough to make it work in Yahoo.
This might not be enough for Outlook on Windows and Windows native client as both of those use Word as a rendering engine and have very poor support for CSS. Thinks like margin:0 auto or max-width won’t work. You will have to rely on conditional comments, tables and eventually mso specific styles to get a proper rendering for Outlook on Windows.
I am trying to display some text in the bottom left of my table but having some issues getting that. What can I try to get that to display?
.table_b10 {
width: 10cm;
height: 2cm;
border: 1px solid;
margin-left: auto;
margin-right: auto;
}
.heading2_b10 {
font-family: calibri;
font-weight: bold;
font-size: 11;
text-align: center;
}
<table class="table_b10">
<tbody>
<tr>
<td class="heading2_b10">Text</td>
</tr>
<tr>
<td class="heading2_b10">LADIES STOCKINGS SYN-BLACK</td>
</tr>
</tbody>
</table>
I think the simplest thing to do would be just to add style="text-align:left;" to the html tag's attribute
Can colspan attribute help you in this case?
.table_b10 {
width: 10cm;
height: 2cm;
border: 1px solid;
margin-left: auto;
margin-right: auto;
}
heading2_b09 {
font-family:calibri;
font-weight: bold;
font-size: 8;
text-align: center;
}
.heading2_b10 {
font-family:calibri;
font-weight: bold;
font-size: 11;
text-align: center;
}
<table class="table_b10">
<tbody>
<tr>
<td class="heading2_b10" colspan="2">Text</td>
</tr>
<tr>
<td class="heading2_b09">LOG-ID: ###</td>
<td class="heading2_b10">LADIES STOCKINGS SYN-BLACK</td>
</tr>
</tbody>
</table>
Explanation: colspan attribute can be applied on a <td> element, it allows you to set how columns wide the element should be.
What is changed?
The first row has colspan="2", that means his width will be extended to 2 columns, like the one under. But this one has really two columns to show where the LOG-ID: ### string is the first, aligned on the left and LADIES STOCKINGS SYN-BLACK one is the second
I'm trying to create a new HTML signature for our company, but I can't seem to get it work nicely on Gmaill app (Android in my test case). Both font-size and line-height changes. I tried different stuff, even deleted the whole HTML signature and try to make a new one with just a few lines to test, but unfortunately I can't get it to work. I tried so many things, that I just have no clue anymore how to fix. I also tried to search for the problem, but I still can't seem to make it work. Please see attached code.
If anyone can help me into the right direction, that would be great. I also included screenshots to show what I mean regarding the Gmail app. As you can see, also text-size is different.
https://imgur.com/mxtU4Bs
https://imgur.com/RXKQt9w
Thanks in advance!
<html>
<head>
<meta charset="utf-8">
<title>html signature</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {margin: 0px; padding: 0px; }
img { border: 0px; }
a { color: #00002E; text-decoration: none; }
h1.title { font-family: Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 5px; }
span.function { font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 15px; color: #00002E; }
#wrapper { width: 100%; max-width: 470px; }
#border { border-left: 1px solid #00002E; }
table.functiondetails { width: 100%; margin-top: 5px; }
table.functiondetails tr { height: 30px; }
table.functiondetails tr td { font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 15px; color: #00002E; }
table.functiondetails tr td.icon { width: 10%; }
table.functiondetails tr td.detail { width: 90%; }
#media screen and (max-width: 768px) {
#wrapper { width: 90%; }
#logoColumn { width: 30%; max-width: 30%; }
#logoColumn img { width: 100%; }
#functionColumn { width: 70%; max-width: 70%; }
}
#media screen and (max-width: 470px) {
#wrapper{ width: 100%; }
}
</style>
</head>
<body>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<table id="wrapper" cellpadding="0" cellspacing="0">
<tr>
<td id="logoColumn">
logo
</td>
<td id="border"></td>
<td id="functionColumn">
<h1 class="title">Name of employee</h1>
<span class="function">Function | Company</span>
<table class="functiondetails" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="icon"><img src="https://www.mvhmedia.nl/email/handtekening/icon-phone.jpg" alt="Bel ons" width="13" height="13"></td>
<td class="detail">+31 (0)6 - 12345678<br>+31 (0)162 -123456</td>
</tr>
<tr>
<td class="icon"><img src="https://www.mvhmedia.nl/email/handtekening/icon-email.jpg" alt="Mail ons" width="13" height="13"></td>
<td class="detail">email#domain.nl</td>
</tr>
<tr>
<td class="icon"><img src="https://www.mvhmedia.nl/email/handtekening/icon-location.jpg" alt="Adresgegevens" width="13" height="13"></td>
<td class="detail">Address line 1<br>Address line 2</td>
</tr>
<tr>
<td class="icon"><img src="https://www.mvhmedia.nl/email/handtekening/icon-arrow.jpg" alt="Website" width="13" height="13"></td>
<td class="detail">domain.nl</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
[1]: https://imgur.com/mxtU4Bs
Campaign Monitor can tell you a lot of information about what CSS properties are supported by the different email platforms. On there it mentions that font-size and line-height are almost universally supported. But it says that style tags in the head or body are not entirely supported, and there is very low support for linked CSS. So your best bet is to try inline styles.
https://www.campaignmonitor.com/css/text-fonts/line-height/
One downside of only using inline styles however is that you can't use media queries. So you could still leave the media queries in a style tag, but they just won't be used by every platform.
I'm trying to vertically align text in two table columns, one of which also has a text input control. Basic code such as:
<td>Caption</td><td>Enter here <input type="text"></td>
No matter how I apply vertical-align to one or both columns, 'Caption' is not on the same level as 'Enter here'. Most times 'Caption' is higher. What's the solution?
Try:
td, input {
vertical-align: middle;
}
If that doesn't work, you will need to post more code to get a good answer.
If you mean that Caption and Enter here are not vertically aligned, despite using the suggested 'vertical-align: middle;' you may have to look into giving the columns a specific or minimum width. I am suspecting that the elements may not be perfectly positioned visually next to each other on the 'reading' level, due to the columns adjusting with top/bottom padding in order to maintain vertical alignment. Therefore being strict about the width of your columns may help.
However I agree with #willoller, if this on top of what the rest of the community suggested isn't working for you, then you need to post relevant code that will help us pinpoint an answer for you.
It should vertical align to middle by default assuming there isn't some other CSS being applied. ... your issue might be related to line height where text and inputs aren't the same .. ..try:
td{
line-height:40px;
height:40px;
}
Thanks for everyone's help so far. The line-height and height additions correct the vertical alignment of the two texts, but also significantly increase the inter-row spacing. This doesn't improve if I set the margin, padding and border to 0. I can't reduce the heights to less than 40px or the alignment fails again.
The following code demonstrates the problems. There's a demo page at www.quinze.co.uk/test/test.html.
<!DOCTYPE HTML>
<html>
<head>
<meta charset=utf-8>
<title>Table test</title>
<style type="text/css">
.s0 {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
}
.s1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
vertical-align: middle;
line-height: 40px;
height: 40px;
}
.s2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
vertical-align: middle;
line-height: 40px;
height: 40px;
padding: 0;
margin: 0;
border-width: 0;
}
</style>
</head>
<body>
<pre> font-family: Arial, Helvetica, sans-serif;
font-size: 13px;</pre>
Col1 captions have different vertical alignment to Col2 but inter-row spacing is good.
<table>
<tr>
<td class="s0">Col1</td>
<td class="s0">Col2<input type="text"></td>
</tr>
<tr>
<td class="s0">Col1</td>
<td class="s0">Col2<input type="checkbox" checked><input type="text" value="ABC"></td>
</tr>
<tr>
<td class="s0">Col1</td>
<td class="s0">Col2<input type="text"></td>
</tr>
</table>
<pre> font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
vertical-align: middle;
line-height: 40px;
height: 40px;
</pre>
The two column captions are now at the same height but the inter-row spacing has increased
<table>
<tr>
<td class="s1">Col1</td>
<td class="s1">Col2<input type="text"></td>
</tr>
<tr>
<td class="s1">Col1</td>
<td class="s1">Col2<input type="checkbox" checked><input type="text" value="ABC"></td>
</tr>
<tr>
<td class="s1">Col1</td>
<td class="s1">Col2<input type="text"></td>
</tr>
</table>
<pre> font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
vertical-align: middle;
line-height: 40px;
height: 40px;
padding: 0;
margin: 0;
border-width: 0;
</pre>
Padding, margins and border reduced to 0 but still greater inter-row spacing
<table>
<tr>
<td class="s2">Col1</td>
<td class="s2">Col2<input type="text"></td>
</tr>
<tr>
<td class="s2">Col1</td>
<td class="s2">Col2<input type="checkbox" checked><input type="text" value="ABC"></td>
</tr>
<tr>
<td class="s2">Col1</td>
<td class="s2">Col2<input type="text"></td>
</tr>
</table>
</body>
</html>
At first, yes I did search and found a lot of similar question and no, non of the solutions worked for me.
Now here is my main problem:
I try to get "a" elements in line and wrap if there are to much to fit inside the parent "td".
But I can either get them in line or warp.
"1st" and "2nd_main_container" are in line. the "1st" has a fixed width "2nd" take the remaining space of "wrapper".
I already tried with float inlineblock adding "width:100%" and my last try (see code) every "a" in a seperate "div" inside another main "div" Floating left. They won't wrap, they just grow the main "div", "td", "tr", "table" and "2nd_main_container". "wrapper" size dose not change.
I guess my problem is that "2nd_main_container" has no fixed width, but thats not an option.
I hope someone can help me with a solution to this. Thanks in advance.
http://jsfiddle.net/p7nhjr08/4/
here my code:
<style>
#wrapper {
width: 100%;
white-space: nowrap;
}
#1st_main_container {
display: inline-block;
padding-left: 16px;
padding-right: 8px;
padding-top: 8px;
padding-bottom: 16px;
width: 400px;
}
#2nd_main_container {
display: inline-block;
padding-left: 8px;
padding-right: 16px;
padding-top: 8px;
padding-bottom: 16px;
vertical-align: top;
}
#2nd_main_container th {
font-family: Tahoma, Geneva, sans-serif;
font-size: 11px;
font-weight: bold;
text-align: right;
}
#2nd_main_container td {
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
font-weight: normal;
text-align: left;
padding-left: 20px;
}
#content {
white-space: normal;
overflow: hidden;
}
#content div {
float:left;
}
#container a {
padding-left: 8px;
padding-right: 8px;
padding-top: 0;
padding-bottom: 0;
}
</style>
<div id="wrapper">
<div id="1st_main_container">
Something
</div>
<div id="2nd_main_container">
<table>
<tbody>
<tr>
<th>
Something:
</th>
<td>
Something
</td>
</tr>
<tr>
<th>
Something:
</th>
<td>
Something
</td>
</tr>
<tr>
<th>
Something:
</th>
<td>
Something
</td>
</tr>
<tr>
<th>
Something:
</th>
<td >
Something
</td>
</tr>
<tr>
<th>
Something:
</th>
<td id="container">
<div id="content">
<div>
<a></a>
</div>
<div>
<a></a>
</div>
...
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
So you have a wrapper with variable width, containing two div-columns. first one with fixed width, and second div shall use the remaining width, correct ?
Maybe you should have a look onto css3 flexbox