So, I'm trying to send an email with information from a user. It should look like this:
But for some reason the css won't work in the email, as it looks like this:
The CSS is as follows:
div.block {
margin: 0;
padding: 0;
padding-bottom: 1.25em;
margin-left: 130px;
}
div.block label {
margin: 0;
padding: 0;
display: block;
font-size: 100%;
padding-top: .1em;
padding-right: .25em;
width: 6em;
text-align: right;
float: left;
}
div.block span {
margin: 0;
padding: 0;
display: block;
font-size: 100%;
}
And my HTML:
<div class="block">
<label>Voornaam:</label>
<span>%voornaam%</span>
</div>
<div class="block">
<label>Achternaam:</label>
<span>%achternaam%</span>
</div>
<div class="block">
<label>E-mailadres:</label>
<span>%email%</span>
</div>
<div class="block">
<label>Telefoon:</label>
<span>%telefoon%</span>
</div>
<div class="block">
<label>Toelichting:</label>
<span>%toelichting%</span>
</div>
<div class="block">
<label>Datum:</label>
<span>%datum%</span>
</div>
CSS in emails is still not supported very well. For the layout you want, using a <table> with inline styles instead of a div-based layout would be the best way to achieve it.
If the images is what you need a table would do fine. You can adjust the padding-left to what you think is best for the layout. You can add a margin-left: 10px or something to the table itself to move the table more to the right.
<table class="emailtable">
<tr>
<td>Voornaam:</td>
<td style="padding-left: 40px;">%voornaam%</td>
</tr>
<tr>
<td>Achternaam:</td>
<td style="padding-left: 40px;">%achternaam%</td>
</tr>
<tr>
<td>E-mailadres:</td>
<td style="padding-left: 40px;">%email%</td>
</tr>
<tr>
<td>Telefoon:</td>
<td style="padding-left: 40px;">%telefoon%</td>
</tr>
<tr>
<td>Toelichting:</td>
<td style="padding-left: 40px;">%toelichting%</td>
</tr>
<tr>
<td>Datum:</td>
<td style="padding-left: 40px;">%datum%</td>
</tr>
A few simple modifications in your CSS will fix that:
div.block {
margin: 0;
padding: 0;
padding-bottom: 1.25em;
margin-left: 130px;
}
div.block label {
margin: 0;
padding: 0;
display: inline-block;
font-size: 100%;
padding-top: .1em;
padding-right: 2em;
width: 6em;
text-align: right;
}
div.block span {
margin: 0;
padding: 0;
display: inline-block;
font-size: 100%;
width: 20em;
}
I prepared a jsfiddle as a demonstration: https://jsfiddle.net/zL2ntzdh/
That said I would like to add that using HTML markup in email messages is a questionable thing. Yes, it does make the message look a bit more shiny. But it comes with huge disadvantages: the message size will get multiplied, the chances of your message being considered SPAM is automatically multiplied, you request ultimate trust from the addressees, so you have to expect that many of them will silently delete the message to prevent security issues.
Related
I'm creating my first basic website using html and css, it's just a simple custom link tree type website where my socials will be laid out on the screen. I'm trying to create 2 columns with 3 rows. Every element in the row is spaced super far away from each other and I can't figure out how to fix this.
HTML Code:
<body class="body">
<div class="container">
<table>
<tr class="row-1">
<td><img src="images/twitch-popout.png"></td>
<td><img src="images/youtube-popout.png"></td>
<tr class="row-2">
<!--<td class="tiktok-popout"><img src="images/tiktok-popout.png"></td>
<td class="twitter-popout"><img src="images/twitter-popout.png"></td> -->
<!--<tr class="link-images">
<td class="instagram-popout"><img src="images/instagram-popout.png"></td>
<td class="discord-popout"><img src="images/discord-popout.png"></td>
</tr> -->
</table>
</div>
</body>
CSS File:
*{
margin: 0;
padding: 0;
}
body {
background: url("images/background.jpg");
background-size: 100% 100%;
background-repeat: no-repeat;
}
.container{
display: block;
height: 91%;
border: 3px solid red;
position: relative;
}
.container td{
margin: 0;
}
.container img{
width: 40%;
}
.row-1{
position: absolute;
align-items: center;
}
I have tried many different things and nothing I have done works
Edit: I'm attaching a picture to show what it looks like as well
As per my comment, here is a way of creating a grid with 2 columns using CSS grid.
.container {
border: 3px solid red;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
.container img {
width: 100%;
height: 80px;
}
<div class="container">
<img src="images/twitch-popout.png">
<img src="images/twitch-popout.png">
<img src="images/twitch-popout.png">
<img src="images/twitch-popout.png">
<img src="images/twitch-popout.png">
<img src="images/twitch-popout.png">
</div>
I'm trying to get the text to display over each individual image, I can't figure out why it's not displaying at all. From what I can tell I don't have the text hidden or anything, it's just not displaying on top of the corrisponding images.
I'm very new to html/css so i'm proberly missing someting quite obvious.
<html>
<body>
<table class="index">
<tr>
<td>
<img src="C:\Users\44074\Desktop\Learnnig\Website\Art\Care-Guide.jpg">
Care guides
</td>
<td>
<img src="C:\Users\44074\Desktop\Learnnig\Website\Art\Prop.jpg">
Propagation
</td>
<td>
<img src="C:\Users\44074\Desktop\Learnnig\Website\Art\Trouble.jpg">
Troubleshooting
</td>
</tr>
<tr>
<td>
<img src="C:\Users\44074\Desktop\Learnnig\Website\Art\Easy.jpg">
Easy plants
</td>
<td>
<img src="C:\Users\44074\Desktop\Learnnig\Website\Art\Pilea.jpg">
Pilea
</td>
<td>
<img src="C:\Users\44074\Desktop\Learnnig\Website\Art\Pets.jpg">
Pets & plants
</td>
</tr>
</table>
</body>
</html>
table.index{
table-layout: fixed;
border-spacing: 25px 35px;
font-size: 20px;
color: #575151;
padding-left: 180px;
padding-right: 180px;
}
table.index td {
height: 220px;
width: 360px;
min-width: 200px;
position: relative;
border: 1px solid black;
background-color: #575151;
vertical-align: middle;
text-align: center;
}
table.index td img {
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
}
div.index {
width: 100%;
}
You should put your text in an HTML element for example p tag: <p>Easy plants</p>
Give the p element a relative position: position: relative;
This will position it over the absolutely positioned image.
If you happen to change the order of the images and the text elements later, you should give the text elements a higher z-index value than the images.
I want to make a formatted paragraph whose image is located in left, the text is located in right with CSS.
However, it looks good when I type a single line text, but the top position is changed when I type two-line text or more.
Its source is on
http://jsfiddle.net/RXrvZ/1883/
and the main part of CSS is:
.post-container {
margin: 20px 20px 0 0;
border: 1px dotted #333;
overflow: auto;
}
.greenbox {
display: block;
border: 1px dotted #383;
width: 100%;
}
.redbox {
display: inline-block;
border: 1px dotted #f33;
width: 70%;
height: 100px;
}
.redbox10 {
display: inline-block;
border: 1px dotted #f33;
width: 20%;
height: 100px;
}
And its HTML code is like:
<div class="greenbox">
<div class="redbox10">
<img src="#">
</div>
<div class="redbox">
One Line Text
</div>
</div>
How can I place the top line same whatever I type in?
Thanks for your help.
Set the left column to align at the top.
.redbox10 {
vertical-align: top;
}
JSfiddle
You need to specify vertical align to be top:
.redbox, img{
display: inline-block;
vertical-align: top;
}
Here's the updated demo
you should use float:
.redbox {
float: left;
}
.redbox10 {
float: left;
}
you can give them a margin for some space.
Demo
Demo With Margin
This could be rather simplified if made using a table.
I hope this helps.
.mainTable{
padding: 10px;
}
.outerRow{
padding: 10px;
}
.imageColumn{
border: 1px solid;
padding: 10px;
vertical-align: top;
}
.textColumn{
border: 1px solid;
padding: 10px;
}
<div class="container">
<table class="mainTable">
<tr class="outerRow">
<td class="imageColumn">
<img src="#"/>
</td>
<td class="textColumn">
One Line Text
</td>
</tr>
<tr class="outerRow">
<td class="imageColumn">
<img src="#"/>
</td>
<td class="textColumn">
Two Lines Text - rai oda bi iod ieo idooosido oiojs oijodif oijoa oijsdf
</td>
</tr>
<tr class="outerRow">
<td class="imageColumn">
<img src="#"/>
</td>
<td class="textColumn">
Three Lines Text - rai oda bi iod ieo idooosido oiojs oijodif oijoa oijsdf hello hello hello hello hello hellohellohellohellohellohello
</td>
</tr>
</table>
</div>
I am trying to make my images a link but it is not working as the #flare div is conflicting with the rest of the layout could anyone tell me how to fix this?
I want the "flare set how it is at www.industrygaming.co.uk/newindex.php
please help. :)
HTML
<div id="content">
<br /><br />
<div id="flare"></div>
<table class="default" style="width: 1000px" align="center">
<tr>
<td class="content" width="33%"><img src="NewImages/Home/Ghosts.png" height="190px" height="190px" border="0"></td>
<td class="content" width="33%"><img src="NewImages/Home/Clan.png" width="200px" height="80px"></td>
<td class="content" width="33%"><img src="NewImages/Home/Fifa.png" width="200px" height="200px"></td>
</tr>
</table>
</div>
CSS
#content
{
float: left;
width: 998px;
margin: 0;
color: #fff;
font-size: 17px;
font-family: Times, serif;
min-height: 150px;
}
#flare
{
position: absolute;
display: block;
background-image: url("NewImages/Home/Optical-Flare.png");
background-repeat: no-repeat;
background-size:990px 700px;
min-width: 998px;
margin-left: 0px;
margin-top: -155px;
min-height: 700px;
}
I don't know about your design, but it is happening due to "position:absolute" to "div#flare."
So just put below code in your css and it will work. Then modify it as per your requirement.
table.default{position: absolute; top: 550px}
I want to center (center+middle) an image, and the title inside h2, in a table column (td)
CSS
.centered
{
text-align:center;
}
HTML
<table class="table table-bordered">
<tbody>
<tr>
<td class="centered"><%= image_tag(prank.image_url, :size => "50x50") %></td>
<td class="centered"><h2><%=prank.category.titleize%></h2></td>
</tr>
I'm using Twitter Bootstrap
You could try:
.centered { vertical-align:middle; text-align:center; }
.centered img { display:block; margin:0 auto; }
check this out http://jsfiddle.net/k6Nvk/1/
just add in your <td> >> <td align="center" valign="middle"><image path></td>
and you can also do this using css check DEMO
Try
.centered{width: 50px; margin: 0px, auto, 0px, auto;}
All you have to do is declare margin from left and right (top and bottom optional):
.center {
margin-left: 25%;
margin-right: 25%;
}
Or you can just use
.center
{
margin-left: auto;
margin-right: auto;
width: 20%;
}
If you don't have to just don't use <table> tag. Use <div> instead.
Here is how I did it.
I call the base twitter css file.
than after i call my default css file
in my default file I have this class
.table-center th, .table-center td {
border-top: 1px solid #DDDDDD;
line-height: 18px;
padding: 8px;
text-align: center;
vertical-align: top;
}
then in my table i do this:
<table class="table table-center ....">...</table>
N.B. align="center" is not supported in HTML 5; see http://www.w3schools.com/tags/tag_td.asp
This should work
.cntr
{
margin: 0 auto;
}
<div class="cntr" style="width: 130px">
<img src="me.jpg" alt="me" style="width: 130px" />
</div>
Give this a try, but not 100% sure if it'll work:
.centered {
display: block;
margin-left: auto;
margin-right: auto;
}
I would try text-align: center; in inline style="".