I do have issues with the positioning of my elements within a table-cell.
I do have a headline, an image and a button within my table cell. The images of the table cell are different in height, so I do want the button to be at the bottom.
What i want is in the below:
!Final Table-Cell Layout1
At the moment the buttons/Link text is right after the images...
.greyCompareTable {
padding: 20px 0px 20px 0px;
background-color: #f5f5f5;
margin-left: -20px;
margin-right: -20px;
display: table;
width: 100%;
border-spacing: 20px;
border-collapse: separate;
table-layout: fixed;
}
.greyCompareRow {
display:table-row;
background-color:green;
}
.greyCompareCell {
display:table-cell;
background-color: #fff;
border: 1px;
border-style: solid;
border-radius: 2px;
border-color: #37b8eb;
position: relative;
}
<div class="greyCompareTable">
<div class="greyCompareRow">
<div class="greyCompareCell">
<h3 style="text-align: center;">
<span id="Kastein_Bosch_Bartoel">Headline</span>
</h3>
<p style="text-align: center;">
<img src="..." border="0" class="tie-appear">
<img style="border: none !important; margin: 0px !important;" src="..." alt="" width="1" height="1" border="0" class="tie-appear">
<img style="border: none !important; margin: 0px !important;" src="..." alt="" width="1" height="1" border="0" class="tie-appear">
</p>
<p style="text-align: center;">
Jetzt ansehen
<img class="aligncenter tie-appear" style="border: none !important; margin: 0px !important;" src="..." alt="" width="1" height="1" border="0">
</p>
</div>
<div class="greyCompareCell">
<h3 style="text-align: center;">
<span id="Bergland_Bartoel">Headline 2</span>
</h3>
<p style="text-align: center;">
<a href="..." target="_blank" rel="noopener">
<img src="..." border="0" class="tie-appear"></a>
<img style="border: none !important; margin: 0px !important;" src="" alt="" width="1" height="1" border="0" class="tie-appear">
<img style="border: none !important; margin: 0px !important;" src="" alt="" width="1" height="1" border="0" class="tie-appear">
This image is a little bit bigger
</p>
<p style="text-align: center;">
Jetzt ansehen
</p>
</div>
<div class="greyCompareCell">
<h3 style="text-align: center;">
<span id="Bergland_Bartoel">Headline 3</span>
</h3>
<p style="text-align: center;">
<a href="..." target="_blank" rel="noopener">
<img src="..." border="0" class="tie-appear"></a>
<img style="border: none !important; margin: 0px !important;" src="" alt="" width="1" height="1" border="0" class="tie-appear">
<img style="border: none !important; margin: 0px !important;" src="" alt="" width="1" height="1" border="0" class="tie-appear">
</p>
<p style="text-align: center;">
Jetzt ansehen
</p>
</div>
</div>
</div>
You can set position: absolute; and bottom: 0; on your button but remember to set the parent element to position:relative in order to use absolute positioning and add a min-height: 300px; to the cell for smaller images.
Here's the full code aligning the hyperlink at the bottom and center. position: absolute will shift it out of it's position and bottom: 0; will pull the element to bottom, but that's not enough since other elements are not positioned well. Adding width: 100%; + margin:0 auto; will horizontally align link.
At last you will have following:
.shortc-button {
bottom: 0;
left: 0;
width: 100%;
margin:0 auto ;
position: absolute;
}
.greyCompareTable {
padding: 20px 0px 20px 0px;
background-color: #f5f5f5;
margin-left: -20px;
margin-right: -20px;
display: table;
width: 100%;
border-spacing: 20px;
border-collapse: separate;
table-layout: fixed;
}
.greyCompareRow {
display:table-row;
background-color:green;
}
.greyCompareCell {
display:table-cell;
background-color: #fff;
border: 1px;
border-style: solid;
border-radius: 2px;
border-color: #37b8eb;
position: relative;
}
.shortc-button {
bottom: 0;
left: 0;
width: 100%;
margin:0 auto ;
position: absolute;
}
<div class="greyCompareTable">
<div class="greyCompareRow">
<div class="greyCompareCell">
<h3 style="text-align: center;">
<span id="Kastein_Bosch_Bartoel">Headline</span>
</h3>
<p style="text-align: center;">
<img src="..." border="0" class="tie-appear">
<img style="border: none !important; margin: 0px !important;" src="..." alt="" width="1" height="1" border="0" class="tie-appear">
<img style="border: none !important; margin: 0px !important;" src="..." alt="" width="1" height="1" border="0" class="tie-appear">
</p>
<p style="text-align: center;">
Jetzt ansehen
<img class="aligncenter tie-appear" style="border: none !important; margin: 0px !important;" src="..." alt="" width="1" height="1" border="0">
</p>
</div>
<div class="greyCompareCell">
<h3 style="text-align: center;">
<span id="Bergland_Bartoel">Headline 2</span>
</h3>
<p style="text-align: center;">
<a href="..." target="_blank" rel="noopener">
<img src="..." border="0" class="tie-appear"></a>
<img style="border: none !important; margin: 0px !important;" src="" alt="" width="1" height="1" border="0" class="tie-appear">
<img style="border: none !important; margin: 0px !important;" src="" alt="" width="1" height="1" border="0" class="tie-appear">
This image is a little bit bigger
</p>
<p style="text-align: center;">
Jetzt ansehen
</p>
</div>
<div class="greyCompareCell">
<h3 style="text-align: center;">
<span id="Bergland_Bartoel">Headline 3</span>
</h3>
<p style="text-align: center;">
<a href="..." target="_blank" rel="noopener">
<img src="..." border="0" class="tie-appear"></a>
<img style="border: none !important; margin: 0px !important;" src="" alt="" width="1" height="1" border="0" class="tie-appear">
<img style="border: none !important; margin: 0px !important;" src="" alt="" width="1" height="1" border="0" class="tie-appear">
</p>
<p style="text-align: center;">
Jetzt ansehen
</p>
</div>
</div>
</div>
Related
I'm trying to put all my elements to the right side of the page using float: right and the only issue that I'm having is the position of the last paragraph, instead of just being below of top paragraph it goes below and moves to the left.
Here you have a JSFiddle to a better understand of my issue.
https://jsfiddle.net/5782o1hg/1/
<div style="height: 100%">
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right"/>
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right; margin: 0 0 0 15px"/>
<p style="font-size: 20px; float: right; margin: 2px 0 0 0">DreamGlass</p>
<br/>
<p style="font-size: 20px; float: right">Ola</p>
</div>
I just want to put the "World" paragraph bellow of the top one without moving to the left.
The easiest way is put 'World' into the 'Hello' paragraph adding a line break between both words:
<div style="height: 100%">
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right"/>
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right; margin: 0 0 0 15px"/>
<p style="font-size: 20px; float: right; margin: 2px 0 0 0">Hello<br /> World</p>
</div>
CSS grid solution:
.grid {
position: absolute;
right: 20px;
display: grid;
grid-template-columns: 1fr 1fr;
}
.items {
justify-self: right;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>CSS grid</title>
</head>
<body>
<div class="grid">
<div class="items item-1">DreamGlass</div>
<div class="items item-2">kiwi.svg</div>
<div class="items item-3">Ola</div>
<div class="items item-4">kiwi.svg</div>
</div>
</body>
</html>
text-align right solution
.p {
text-align: right;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>text-align right solution</title>
</head>
<body>
<div class="wrapper">
<p class="p">paragraph-1</p>
<p class="p">paragraph-2</p>
</div>
</body>
</html>
<div style="height: 100%;">
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right"/>
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right; margin: 0 0 0 15px"/>
<p style="font-size: 20px; float: right; margin: 2px 0 0 0;width:100%;text-align:right;">Hello</p>
<p style="font-size: 20px; float: right;width:100%;text-align:right;">World</p>
</div>
thats all...
You can create "wrapper" <div> and put in your paragraphes
Result on JSFiddle
<div style="height: 100%">
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right" />
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right; margin: 0 0 0 15px" />
<div style="float:right;">
<p style="font-size: 20px; float: right; margin: 2px 0 0 0">DreamGlass</p>
<br/>
<p style="font-size: 20px; float: right">Ola</p>
</div>
</div>
You could add a negative margin-right to the world paragraph.
<div style="height: 100%">
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right"/>
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right; margin: 0 0 0 15px"/>
<p style="font-size: 20px; float: right; margin: 2px 0 0 0">Hello</p>
<br/>
<p style="font-size: 20px; float: right; margin-right: -50px">World</p>
</div>
Wrap the two paragraphs into a div with style = "float: right;"
Replace <p> tags with <span> and adjust styles in both as needed
<div style="height: 100%">
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right"/>
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="float: right; margin: 0 0 0 15px"/>
<div style="float: right;">
<span style="font-size: 20px; margin: 2px 0 0 0">DreamGlass</span>
<br />
<span style="font-size: 20px; float: right; margin: 2px 4px 0 0">Ola</span>
</div>
</div>
Better you can use flexbox instead of float
<div style="height: 100%; display: flex; flex-direction: column; align-items: flex-end;">
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50"/>
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50"/>
<p style="font-size: 20px; margin: 2px 0 0 0">DreamGlass</p>
<p style="font-size: 20px;">Ola</p>
</div>
Still not want to use flexbox then just making some changes on your code will do this for you. Remove float and add style "text-align: right;" to the parent. Also add a line break after image
<div style="height: 100%; text-align: right;">
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" /><br>
<img src="https://s.cdpn.io/3/kiwi.svg" width="50" height="50" style="margin: 0 0 0 15px"/><br>
<p style="font-size: 20px; margin: 2px 0 0 0">DreamGlass</p>
<p style="font-size: 20px;">Ola</p>
</div>
I have 5 icons images. and i want to position them as follow:-
and to guarantee consistent layout on all the screen sizes, i added a table without boarder and i position the icons inside the table cells as shown above.
But now i want to change the layout to be something as follow:-
where using tables will no longer work.. so can anyone adivce on which appraoch i can use to position my icons as shown in the second picture? and to guranteee that the images will always be shown in the desored layout even on small sized screens.. as i am adding the above html inside iframes on many web pages.
Regards
here is my markup for the table:-
<table class="ms-rteTable-0 " cellspacing="0" cellpadding="0" style="width: 15%; height: 198px;">
<tbody>
<tr class="ms-rteTableEvenRow-0">
<td class="ms-rteTableEvenCol-0" style="width: 30px; height: 16px;"><a title="" href="" target="_blank"><img src="" alt="" style="margin: 0px; width: 60px; height: 59px;"/></a></td>
<td class="ms-rteTableOddCol-0" style="width: 20px; height: 16px;"><a title="" href="/" target="_blank"><img src="" alt="" style="margin: 0px; width: 60px; height: 59px;"/></a></td>
<td class="ms-rteTableEvenCol-0" style="width: 30px; height: 16px;"><a title="" href="" target="_blank"><img src="" _moz_resizing="true" alt="" style="margin: 0px; width: 60px; height: 59px;"/></a></td>
</tr>
<tr class="ms-rteTableOddRow-0">
<td class="ms-rteTableEvenCol-0" rowspan="1" style="width: 30px; height: 76px;"><a title="" href="" target="_blank"><img src="" alt="" style="margin: 0px; width: 60px; height: 59px;"/></a></td>
<td class="ms-rteTableOddCol-0" rowspan="1" style="width: 20px; height: 76px;"></td>
<td class="ms-rteTableEvenCol-0" rowspan="1" style="width: 30px; height: 76px;"><a title="" href="" target="_blank"><img src="" alt="" style="margin: 0px; width: 60px; height: 59px;"/></a></td>
</tr>
</tbody>
</table>
Okay. So I tried your code and saw what it does. And what you want can be done using this :-
This is CSS code put it in in the head tag
.icon {
width: 60px;
height: 59px;
}
This is the image part:- setting width and using overflow will prevent auto-wrapping.
<div style="width: 190px; overflow: hidden;">
<img class='icon' src="">
<img class='icon' src="">
<img class='icon' src="">
<div style="margin-top: 4ex; margin-left:4.5ex;">
<img class='icon' src="">
<img class='icon' src="">
<div>
</div>
Thats how it will look.
How do I make these photos all go in the center of the webpage? this is my html code
<html>
<body>
<div id="travel_photos">
<img style="display: inline; margin: 0 10px; title="branson" src="branson.jpg" alt="" width="150" height="50"/>
<img style="display: inline; margin: 0 10px; title="cancun" src="cancun.jpg" alt="" width="150" height="50"/>
<img style="display: inline; margin: 0 10px; title="denver" src="denver.png" alt="" width="150" height="50"/>
<img style="display: inline; margin: 0 10px; title="destin" src="destin.png" alt="" width="150" height="50"/>
<img style="display: inline; margin: 0 10px; title="PV" src="PV.png" alt="" width="150" height="50"/>
</body>
</html>
If you're trying to center the images horizontally, try this: https://jsfiddle.net/a5u3q1w5/2/
HTML:
<div id="travel_photos">
<img title="branson" src="http://www.catster.com/wp-content/uploads/2017/08/A-fluffy-cat-looking-funny-surprised-or-concerned.jpg"/>
<img title="branson" src="http://www.petmd.com/sites/default/files/petmd-cat-happy-13.jpg"/>
<img title="branson" src="https://static.pexels.com/photos/126407/pexels-photo-126407.jpeg"/>
</div>
CSS:
#travel_photos > img {
width: 300px;
height: 100px;
margin: 0 auto;
display: block;
}
Please try this:
<html>
<body>
<img style="display: block; margin:auto;" title="branson" src="branson.jpg" alt="" width="150" height="50"/>
<img style="display: block; margin:auto;" title="cancun" src="cancun.jpg" alt="" width="150" height="50"/>
<img style="display: block; margin:auto;" title="denver" src="denver.png" alt="" width="150" height="50"/>
<img style="display: block; margin:auto;" title="destin" src="destin.png" alt="" width="150" height="50"/>
<img style="display: block; margin:auto;" title="PV" src="PV.png" alt="" width="150" height="50"/>
</body>
</html>
I'm trying to display two columns side by side (the one on the left has 4 items and the one on the right has 3, totalling 7 items altogether) and I have:
#wrap{
width:600px;
margin:0px auto;
column-count: 2;
}
#left_col {
float:left;
width:200px;
}
#right_col{
float: right;
width: 200px;
}
<div id="wrap">
<div id="left_col">
<img src="number1.png"alt="number1" border="0" align="top" height="65" width="75"/>num1
<img src="number2.png"alt="number2" border="0" align="top" height="65" width="75"/>num2
<img src="number3.png"alt="number3" border="0" align="top" height="75" width="65"/>num3
<img src="number4.png"alt="number4" border="0" align="top" height="65" width="75"/>num4
</div>
<div id="right_col">
<img src="num1.png"alt="num1" border="0" align="top" height="65" width="75"/>number1
<img src="num2.png"alt="num2" border="0" align="top" height="65" width="75"/>number2
<img src="num3.png"alt="num3" border="0" align="top" height="65" width="75"/>number3
</div>
</div>
And my problem is that when I run it, the links/images/text in the left_col doesn't seem to be displayed as one item on each row like in the right_col and it's not showing the text together as it seems to be on the line below it.
Add display:block on the a tag:
#wrap{
width: 600px;
margin: 0px auto;
}
#left_col {
float: left;
width: 200px;
}
#right_col{
float: right;
width: 200px;
}
a {
display: block;
}
<div id="wrap">
<div id="left_col">
<img src="http://lorempixel.com/75/65/technics/1" alt="number1" height="65" width="75"/> Number 1
<img src="http://lorempixel.com/75/65/technics/2" alt="number2" height="65" width="75"/> Number 2
<img src="http://lorempixel.com/65/75/technics/3" alt="number3" height="75" width="65"/> Number 3
<img src="http://lorempixel.com/75/65/technics/4" alt="number4" height="65" width="75"/> Number 4
</div>
<div id="right_col">
<img src="http://lorempixel.com/75/65/technics/5" alt="num1" height="65" width="75"/> Number 1
<img src="http://lorempixel.com/75/65/technics/6" alt="num2" height="65" width="75"/> Number 2
<img src="http://lorempixel.com/75/65/technics/7" alt="num3" height="65" width="75"/> Number 3
</div>
</div>
Though, ideally you should do this using lists.
#wrap{
width:600px;
margin:0px auto;
column-count: 2;
}
#left_col {
float:left;
width:200px;
}
#left_col a {
display: block;
}
#right_col{
float: right;
width: 200px;
}
<div id="wrap">
<div id="left_col">
<img src="number1.png"alt="number1" border="0" align="top" height="65" width="75"/>num1
<img src="number2.png"alt="number2" border="0" align="top" height="65" width="75"/>num2
<img src="number3.png"alt="number3" border="0" align="top" height="75" width="65"/>num3
<img src="number4.png"alt="number4" border="0" align="top" height="65" width="75"/>num4
</div>
<div id="right_col">
<img src="num1.png"alt="num1" border="0" align="top" height="65" width="75"/>number1
<img src="num2.png"alt="num2" border="0" align="top" height="65" width="75"/>number2
<img src="num3.png"alt="num3" border="0" align="top" height="65" width="75"/>number3
</div>
</div>
Put 150 px for the width of your columns:
#wrap{
width:600px;
margin:0px auto;
column-count: 2;
}
#left_col {
float:left;
width:150px;
}
#right_col{
float: right;
width: 150px;
}
I'm very new to HTML and have been trying to build a HTML signature, I've managed to get it to work in a number of email clients and look how I want but sometimes, for instance on iPhone and in Hotmail/Outlook the social media icons in the second cell move below the company logo. Is there something I have missed or can improve upon so that they stay inline with the rest of the signature?
Below is the current code - I probably have things in the code that either don't need to be there or seem a bit strange but this is best I've managed to achieve.
<div id="sig" style="min-width: 400px; min-height: 130px; max-width: 600px; max-height: 150px; padding: 5px 0 0 5px;">
<tbody>
<tr>
<td>
<img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Signature-for-forum.jpg"alt=" width="500" height="119" alt="Lozi Designs" style="float: left; border: none;"/></td>
<td valign="bottom"><a href="http://www.facebook.com/lozidesigns"> <img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/FB-LBS.jpg" alt="www.facbeook.com/lozidesigns" width="38" height="38" style="margin: 0; border: 0; padding: 1.5; display: block;">
<a href="http://www.instagram.com/lozi_designs"> <img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Instagram-LBS.jpg" alt="www.instagram.com/lozi_designs" width="38" height="38" style="margin: 0; border: 0; padding: 1.5; display: block;">
<a href="http://www.lozidesigns.com"> <img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Home-LBS.jpg" alt="www.lozidesigns.com" width="38" height="38" style="margin: 0; border: 0; padding: 1.5; display: block;">
</td>
<div style="clear:both"></div>
Many thanks
If you mean to leave images in the same line you should use display : inline instead of display : block
<div id="sig" style="min-width: 400px; min-height: 130px; max-width: 600px; max-height: 150px; padding: 5px 0 0 5px;">
<tbody>
<tr>
<td>
<img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Signature-for-forum.jpg"alt=" width="500" height="119" alt="Lozi Designs" style="float: left; border: none;"/></td>
<td valign="bottom"><a href="http://www.facebook.com/lozidesigns"> <img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/FB-LBS.jpg" alt="www.facbeook.com/lozidesigns" width="38" height="38" style="margin: 0; border: 0; padding: 1.5; display: inline;">
<a href="http://www.instagram.com/lozi_designs"> <img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Instagram-LBS.jpg" alt="www.instagram.com/lozi_designs" width="38" height="38" style="margin: 0; border: 0; padding: 1.5; display: inline;">
<a href="http://www.lozidesigns.com"> <img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Home-LBS.jpg" alt="www.lozidesigns.com" width="38" height="38" style="margin: 0; border: 0; padding: 1.5; display: inline;">
</td>
<div style="clear:both"></div>
edit Updated codepen and litmus.
Try this. codepen. Looks the same in all litmus tests.
edit updated HTML
<div id="sig" style="min-width:400px;min-height:130px;max-width:600px;max-height:150px;padding:5px 0 0 5px;">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td rowspan="3">
<img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Signature-for-forum.jpg" width="454" height="117" alt="Lozi Designs" border="0" style="display:block;"/>
</td>
<td valign="middle">
<img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/FB-LBS.jpg" alt="www.facbeook.com/lozidesigns" width="38" height="38" border="0" style="display:block;"/>
</td>
</tr>
<tr>
<td valign="middle">
<img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Instagram-LBS.jpg" alt="www.instagram.com/lozi_designs" width="38" height="38" border="0" style="display:block;">
</td>
</tr>
<tr>
<td valign="middle">
<img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Home-LBS.jpg" alt="www.lozidesigns.com" width="38" height="38" border="0" style="display:block;">
</td>
</tr>
</table>
</div>
Be sure to validate your html code. You used table elements but didn't surround them with a <table> tag, there were more than one alt text given for the same images, and some of your quotes did not were not closed (not the width attribute below as an example).
Open:
width="122 height="122"
Closed:
width="122" height="122"
edit
I cleaned up some of the styles in the image (you didn't need to float the logo), and removed cellpadding/cellspacing by setting them to zero in the table element. I rechecked Litmus and the social media icons appear as I believe they should.
Try this:
<table>
<tr><td>
<div style="float:left;"><img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Signature-for-forum.jpg" style="width:100%;max-width:600px;"></div></td><td>
<div width="38px" style="display:inline;">
<img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/FB-LBS.jpg" alt="www.facbeook.com/lozidesigns" width="100%" style="max-width:38px;"><br>
<img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Instagram-LBS.jpg" alt="www.instagram.com/lozi_designs" width="100%" style="max-width:38px;"><br>
<img src="http://www.lozidesigns.com/wp-content/uploads/2015/09/Home-LBS.jpg" alt="www.lozidesigns.com" width="100%" style="max-width:38px;"></div></td></tr></table>
It should be fully responsive for any email client or mobile device.