Using this html code:
<div class="container-fluid" >
<div class="row">
<div class="col-md-3" >
<table id="Table" width="100%">
<tr>
<td align="left" valign="middle" >
<img src="MyImage" width="220" height="200">
</td>
</tr>
<tr>
<td width="251" height="400" align="left" valign="top" >
<p style="margin-top: 20px; margin-bottom: 0px;">
<img src="MyImage2" width="220" height="200">
</p>
</td>
</tr>
</table>
</div>
<div class="col-md-9 " >
<form id="form1" class="form-horizontal" runat="server" >
<div " align="left" >
Some other HTML stuff
</div>
</form>
</div>
</div>
</div>
It works fine, however, I need to add a left margin of 50px before MyImage2.
So I update my code this way.
<div class="container-fluid" >
<div class="row">
<div class="col-md-3" >
<table id="Table" width="100%">
<tr>
<td align="left" valign="middle" >
<img src="MyImage" width="220" height="200">
</td>
</tr>
<tr>
<td width="251" height="400" align="left" valign="top" style="margin-left: 50px;">
<!-----------------50 px margin added------------->
<p style="margin-top: 20px; margin-bottom: 0px;margin-left: 50px;">
<img src="MyImage2" width="220" height="200">
</p>
</td>
</tr>
</table>
</div>
<div class="col-md-9 " >
<form id="form1" class="form-horizontal" runat="server" >
<div " align="left" >
Some other HTML stuff
</div>
</form>
</div>
</div>
</div>
With this code I have a responsivity issue.
If I reduce the window size, the "other HTML stuff" displayed on the right frame overwrites the image2 of 50 pixels.
How can I have the right frame not to overwrite the right part of my image2?
I tried to increase the width of the td and / or table tage, it did not work for me. So hopefully someone can help me there.
EDIT:
you can check the issue on this link:
http://www.bootply.com/t1hF1cHuD2
reduce the window to have right frame to overwrite the left frame (which is what I want not to happen)
Try not to use inline styles as sometimes it can cause problems, I suggest making a section in the header and try putting margin-left:50px !important; and see if that works. Also you could use position:relative; and using top left right bottom properties to move it where you want.
The layout using columns with a width percentage (25%). So if you do not want to change the logic of the layout, the simplest solution is to add the same margin to the right content to always stay away from the image.
<div align="left" style="margin-left:50px;" >
Here the example. With the colors you can see what happens to your columns (and contents) in responsive: JS Fiddle link
Related
Looking to allocate most of the row space to line up with the container to the right column of a row. I've used
Column1
Column2
This seems to resolve the issue on some online HTML editors, but for some reason, it has no effect on the internal editor I'm using which is mainly focused on MarkDown / HTML / In-Line CSS
Is there a way that this can be done preferably using in-Line CSS?
<div class="main-container" style="display: flex;">
<div class="image-container">
<img
src="https://lh3.googleusercontent.com/coMv1dl31PCfEs6essJoEUwVryaqKHKQvENdZ_WYpN-PXa8Qfitkg3grQxIVN22W5A"
hspace="50" width="150" height="150">
</div>
<div class="content-container" style="width: 600px;">
<h3>Subject Title</h3>
<h4>Subject Description</h4>
<table>
<tr>
<td>
<p>
<center><span style="font-weight:bold">Sample Service</span></center>
</p>
</td>
<td>Sample Service Details Will be listed here!!!!!!!!!!!</td>
</tr>
<tr>
<td>
<p>
<center><span style="font-weight:bold">Contact Us</span></center>
</p>
</td>
<td style="padding-left: 20px;">
<ul style="padding-left: 15px; margin: 0;">
<li style="padding-bottom: 10px;">
Email Sample
</li>
<li><a>Skype: Sample Contact</a></li>
</ul>
</td>
</tr>
</table>
</div>
</div>
Looking to have an image on the left side of a container, however, if the content is too short or too long I'd have to adjust the height of the image proportionally to prevent the content from sliding below the image. The reason I want to contain the Image and the content in the container is to ensure that the image is coherent throughout the entirety of the pages.
We can use HTML / in-line CSS / Markdown to make this adjustment. Perhaps I believe we may need to use Flexbox
I've attached the code below, I've used Grid and a table, and I don't really like it
<div style=“display:grid; grid-template-columns:auto 1fr”>
<div>
<h1> <img src=“https://image.shutterstock.com/image-vector/sample-stamp-grunge-texture-vector-260nw-1389188336.jpg”
align=“left”
hspace=“30"
width=“100”
height=“100">
</div>
<div>
<h3>TITLE</h3>
Description for Title
<table>
<tr>
<td><strong>BLAH:</strong></td>
<td style=“padding-left:20px”><p>Updates are made annually or more frequently if needed<p/></td>
</tr>
<tr>
<td style=“vertical-align:top”><strong>Contact Us:</strong></td>
<td style=“padding-left:20px”>
<ul style=“padding-left: 15px; margin: 0px”>
<li style=“padding-bottom: 10px”><a href=“mailto:sample#email.com”>Email: Jane Doe</a></li>
<li><a>Skype: Sample</a></li>
</ul>
</br>
</td>
</tr>
</table>
</div>
</div>
--Most Recent
The image is on the left side but the table seems to overlap the image
This is what it currently looks like
edit 2
I've edited this again for you if this needs to be inline styles, i've gave a class name on the different containers so you can clearly see how this is working,
your image can just go into image-container and your content can go in content-container. You can add size to the containers, padding, margin etc.. to adjust the layout that you want, but this should help with the basic setup for your HTML.
<div class="main-container" style="display: flex;">
<div class="image-container">
<img
src=“https://image.shutterstock.com/image-vector/sample-stamp-grunge-texture-vector-260nw-1389188336.jpg”
hspace="30" width="100" height="100">
</div>
<div class="content-container">
<h3>TITLE</h3>
<h4>Description for Title</h4>
<table>
<tr>
<td><strong>BLAH:</strong></td>
<td style="padding-left: 20px;">
<p>Updates are made annually or more frequently if needed</p>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><strong>Contact Us:</strong></td>
<td style="padding-left: 20px;">
<ul style="padding-left: 15px; margin: 0;">
<li style="padding-bottom: 10px;">
Email: Jane Doe
</li>
<li><a>Skype: Sample</a></li>
</ul>
</td>
</tr>
</table>
</div>
</div>
Here a flexbox example:
HTML
<div style="display: flex; flex-flow: row nowrap;">
<div style="flex: 1 auto;">
<img src=“https://image.shutterstock.com/image-vector/sample-stamp-grunge-texture-vector-260nw-1389188336.jpg” hspace="30" width="100" height="100">
</div>
<div style="flex: 1 auto;">
<h3>TITLE</h3>
Description for Title
<table>
<tr>
<td><strong>BLAH:</strong></td>
<td style=“padding-left:20px”>
<p>Updates are made annually or more frequently if needed
<p />
</td>
</tr>
<tr>
<td style=“vertical-align:top”><strong>Contact Us:</strong></td>
<td style=“padding-left:20px”>
<ul style=“padding-left: 15px; margin: 0px”>
<li style=“padding-bottom: 10px”><a href=“mailto:sample#email.com”>Email: Jane Doe</a></li>
<li><a>Skype: Sample</a></li>
</ul>
</td>
</tr>
</table>
</div>
</div>
DEMO HERE
I am trying to create an email that is properly visible in both the online version of outlook and gmail. I seem to have it working fine in gmail but have encountered a weird issue when it comes to outlook. I have two identical elements with an image inside. When I view the first one in outlook it strips the entire element of the inline style properties. It then works perfectly fine on the second with identical code. (see screenshot) I know there are weird inconsistencies between email clients but I am not sure what is going on here. If anyone has any ideas please let me know.
I looked around and the only person who seemed to have a similar problem to me was this question but I at least haven't found any stray semicolons like was the issue there.
<table>
<td align="left">
<div id="wrapper" style="width: 600px;background-image: linear-gradient(#15dbff, #6aff90);margin-top: 0px;position: absolute;top: 0px;">
<table height="20px" width="600px">
<tr height="20px" width="600px"></tr>
</table>
<div id="heading" style="width: 452px;height: 131px;background-color: white;margin: auto;margin-top: 20px;border-radius: 25px;">
<img id="headerimg" src="https://kevinuulong.com/images/KLlogocolredcircle.png" style="width: 131px; margin-left: 150px;">
</div>
<div id="body" style="width: 392px;background-color: white;margin: auto;margin-top: 20px;border-radius: 25px;padding: 30px;">
<p id="greeting">Mr. Somebody,</p>
<p id="mainbody">This is some sample text. It should be using the Montserrat font family. This is what a link should look like. Any images should be inside a div like this.
<div class="bodyimage" style="width: 392px;height: 200px;overflow: hidden;border-radius: 25px;margin-bottom: 10px;"><img src="https://source.unsplash.com/random/?colors/392x200"></div>
<div class="bodyimage" style="width: 392px;height: 200px;overflow: hidden;border-radius: 25px;margin-bottom: 10px;"><img src="https://source.unsplash.com/random/?colors/392x200"></div>
</p>
<p id="signature">Thanks,<br>Kevin Long</p>
</div>
<div id="contact" style="width: 452px;background-color: white;margin: auto;margin-top: 20px;margin-bottom: 20px;border-radius: 25px;">
<table>
<th style="width: 50%;"> <img id="contactimg" src="https://kevinuulong.com/images/KLlogocolredcircle.png" style="width: 120px;"></th>
<th style="width: 50%;">kevinuulong.com<br><br>
<a
id="btn" href="mailto:someone#example.com" style="text-decoration: none;background: #5284ff;background-repeat: repeat-x;background-size: 100% 2px;background-position: 0 95%;color: white;padding-left: 50px;padding-right: 50px;padding-top: 10px;padding-bottom: 10px;border-radius: 20px;">Contact Me</a>
</th>
</table>
</div>
<table height="20px" width="600px">
<tr height="20px" width="600px"></tr>
</table>
</div>
</td>
</table>
The basic requirements for Outlook are, for each image, to have the width and height attributes, i.e.:
<img width="392" height="200" src="https://source.unsplash.com/random/?colors/392x200">
Div's don't tend to play well with Outlook; that's why we're still using tables for layout.
If you need the image to be responsive, add this in the style:
<img width="392" height="200" style="width:100%;height:auto;max-width:392px" src="https://source.unsplash.com/random/?colors/392x200">
I can get two divs next to each other using display: inline-block; in the style attribute, but then the div on the right side is aligned on the bottom rather than at the top. So I tried floating the divs and I get another issue...
If I use floats like so:
<div style="width:100%">
<div style="width:25%; float:left;">
<asp:HyperLink ID="hlPic" runat="server" Target="_blank" ToolTip="Click to open this picture.">
<asp:Image ID="imgPic" Width="256px" Height="256px" runat="server" ToolTip="Picture" />
</asp:HyperLink>
</div>
<div style="width:75%; float:right;">
<table style="width:100%">
<tr>
<td>
<h2 style="display:inline;"><asp:HyperLink ID="hlCGValue" runat="server" ToolTip="Go to this corporate group.">[hlCGValue]</asp:HyperLink></h2>
</td>
</tr>
<tr>
<td>
<h3 style="display: inline;">
<asp:Label ID="lblCompanyNameValue" runat="server"></asp:Label></h3>
<asp:Label ID="lblCompanyID" runat="server" Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:HyperLink ID="hlWebsiteValue" runat="server" Target="_blank">[hlWebsiteValue]</asp:HyperLink>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblAssignedToValue" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</div>
I get the following layout:
Notice the table with text is so far away from the picture...I'd like to move it right next to the picture. I tried doing it using display: inline-block but then the table of data would be next to the picture however it would sit at the bottom of the div rather then at the top (probably due to the size of the pic). If it helps the max size of the picture should only be 256px x 256px.
Can anyone help me with my CSS / HTML to make this look right...
Rendered html
<div style="width:100%">
<div style="width:25%; float:left;">
<a id="MainContent_hlPic" title="Click to open this picture." href="/Attachments/Pictures/56_27_11_2013_23_26_11_2013_Penguins.jpg" target="_blank"><img id="MainContent_imgPic" title="Picture" src="/Attachments/Pictures/56_27_11_2013_23_26_11_2013_Penguins.jpg" style="height:256px;width:256px;" /></a>
</div>
<div style="width:75%; float:right;">
<table style="width:100%">
<tr>
<td>
<h2 style="display:inline;"><a id="MainContent_hlCGValue" title="Go to this corporate group." href="../Corporate/Details.aspx?CorporateGroupID=39">Ford</a></h2>
</td>
</tr>
<tr>
<td>
<h3 style="display: inline;">
<span id="MainContent_lblCompanyNameValue">Ford Global Test Co.</span></h3>
</td>
</tr>
<tr>
<td>
<a id="MainContent_hlWebsiteValue" href="http://www.ford.com" target="_blank">www.ford.com</a>
</td>
</tr>
<tr>
<td>
<span id="MainContent_lblAssignedToValue">Name</span>
</td>
</tr>
</table>
</div>
</div>
You can use display: inline-block. When you want them aligned at the top, you must use vertical-align: top
<div>
<div id="#first">
<!-- image -->
</div>
<div id="second">
<!-- table -->
</div>
</div>
#first, #second {
display: inline-block;
vertical-align: top;
}
JSFiddle
The problem with display: inline-block is that the whitespace between your two div elements is NOT ignored. The result is that the width of your 2 divs + the width of the whitespace is more than 100%. That's why the second div appears under the first one.
One way to fix this is to set font-size: 0 on the parent element, but there are other solutions:
http://davidwalsh.name/remove-whitespace-inline-block
CSS is my weak side and now I'm trying to improve it, can you please help me to spot what's the problem is, moreover which css style I'm missing.
<table>
<tr>
<td style=width:"177px; height:92px"><img src="logo.png"></td>
<td rowspan="2"><img src="img2.png"></td>
</tr>
<tr>
<td style=width:"177px; height:100px"><img src="img1.png"></td>
</tr>
</tr>
</table>
UPDATE:
I forgot to mention that I was doing HTML email so solved my issue. Thanks for your help
I think you just need to make the table default CellSpacing and CellPadding 0 (assuming the top picture in your post is the desired result)
<table cellpadding=0 cellspacing=0 >
Although DIV's may be easier
<div>
<div style = width:"177px; height:92px; float:left;">
<img src="logo.png"><br />
<img src="img2.png">
</div>
<div style=width:"177px; height:100px; float:left;">
<img src="img1.png">
</div>
</div>
Then, let's take it 1 step further
<style>
.wrapper
{
background-color:#ccc;
padding:5px;
}
.content
{
width:177px;
height:100px; /*Made them both 100px although one was 92px, this may not be correct*/
float:left;
}
</style>
<div class="wrapper">
<div class="content">
<img src="logo.png"><br />
<img src="img2.png">
</div><!--/content-->
<div class="content">
<img src="img1.png">
</div><!--/content-->
</div><!--/wrapper-->
The property you are looking for may be border-spacing, E.G. border-spacing: 0; (other table specific CSS properties) however you may wish to consult this topic first: Why not use tables for layout in HTML?
Try This one:
css
table {border:1px solid #ccc;
.logo{ width:100px; }.img2{ width:300px }
HTML
<table cellpadding="0" cellspacing="0">
<tr>
<td class="logo">
<img src="logo.png" /><br />
<img src="img1.png">
</td>
<td class="img2"><img src="img2.png"></td>
</tr>
</table>
height is the problem. Decrease the height of logo.png image.