mjml align mj-wrapper background-position to the right - email

I'm trying without succes to align the background-position for an mj-wrapper to the right but I don't know how to do it.
Here is my code:
<mj-wrapper mj-class="hero" border="1px solid #000000" padding="50px 30px" background-url="https://i.picsum.photos/id/873/214/135.jpg" background-repeat="no-repeat">
<mj-section border-top="1px solid #aaaaaa" border-left="1px solid #aaaaaa" border-right="1px solid #aaaaaa" padding="20px">
<mj-column>
<mj-text color="#009f82" font-size="17px" font-weight="bold" padding="20px 0 40px 0">
Lorem Ipsum,
</mj-text>
<mj-text>
Lorem Ipsum 2
</mj-text>
<mj-text>
Lorem Ipsum 3
</mj-text>
</mj-column>
</mj-section>
<mj-section border-left="1px solid #aaaaaa" border-right="1px solid #aaaaaa" padding="20px" border-bottom="1px solid #aaaaaa">
<mj-column border="1px solid #dddddd">
<mj-text css-class="hero-style" padding="20px"> First line of text !! </mj-text>
<mj-divider border-width="1px" border-style="dashed" border-color="lightgrey" padding="0 20px" />
<mj-text padding="20px"> Second line of text </mj-text>
</mj-column>
</mj-section>
</mj-wrapper>
I have tried with:
<mj-class name="hero" text-align="right" text-align="right" background-color="yellow" background-position="top right" />
And with:
</mj-attributes>
<mj-style inline="inline">
.hero-style {
text-align: right;
background-color: red;
color: red;
background-position: top right;
}
</mj-style>
But it doesn't work. Any help?

Simply just add it as an attribute to <mj-wrapper />:
<mj-wrapper
background-position="right"
background-url="https://i.picsum.photos/id/873/214/135.jpg"
background-repeat="no-repeat"
>
...
</mj-wrapper>
Note, there are could be some limitations/issues in outlook. I am not sure.
Follow the link to see the whole list (scroll bottom): https://www.npmjs.com/package/mjml-wrapper
P.S.: works for MJML version #^4.7.

Related

MJML edm how to make a column's height same as the other column?

I am trying to achieve the following design on my EDM:
I have tried the following:
<mj-section
padding="12px 48px 12px"
background-color="#FFF"
>
<mj-column width="50%">
<mj-image
src="assets/img/image-1.png"
width="231px"
padding="0"
align="center"
/>
</mj-column>
<mj-column width="50%" background-color="#F0F0F0">
<mj-text
color="#101010"
font-size="29px"
line-height="35px"
font-family="Arial, sans-serif"
font-weight="700"
align="right"
padding="0"
>
<p>Lorem ipsum dolor sit amet</p>
</mj-text>
</mj-column>
</mj-section>
but I am getting not my desired result:
How can I make the 2nd column's height fill the whole section to equal the height of the other column?
Hope somebody can help, thanks!
You can give the whole row (or both columns) the same background color
<mj-section
padding="12px 48px 12px"
background-color="#fff">
<mj-section
background-color="#F0F0F0">
<mj-column width="50%" background-color="#F0F0F0">
<mj-image
src="assets/img/image-1.png"
width="231px"
padding="0"
align="center"/>
</mj-column>
<mj-column width="50%" background-color="#F0F0F0">
<mj-text
color="#101010"
font-size="29px"
line-height="35px"
font-family="Arial, sans-serif"
font-weight="700"
align="right"
padding="0"
>
<p>Lorem ipsum dolor sit amet</p>
</mj-text>
</mj-column>
</mj-section>
</mj-section>
Let me know if that works.

iTextSharp XMLWorker does not work on css border-collapse: collapse;

The HTML code is:
<html>
<head>
<title>test</title>
<style type="text/css">
table {
border-collapse: collapse;
}
table tr td {
border: 2px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<td>row 1 cell 1</td>
<td>row 1 cell 2</td>
</tr>
<tr>
<td>row 2 cell 1</td>
<td>row 2 cell 2</td>
</tr>
</table>
</body>
</html>
But in the output PDF file, the inner borders are doubled width.
I'm using the latest iTextSharp 5.5.6 & XML Worker 5.5.6.
Anyone has any idea why?
Thanks!
Leo
border-collapse: collapse; appears to not actually collapse the borders, but just move them really close to each other, if you look carefully you can see a fine line in the middle of the fat border. I could only see it when my pdf is opened in Chrome, not in my pdf-reader.. Here is a screenshot showing what i mean:
So I ended up setting the top and left borders of the table, and the right and bottom borders of the cells in the table, which gave me the desired thin line of only 1px instead of 2px, (AKA: only one line, instead of two lines)
.tableborder {
border-collapse: collapse;
border-spacing: 0;
border-top-color: black;
border-top-width: 1px;
border-top-style: solid;
border-left-color: black;
border-left-width: 1px;
border-left-style: solid;
}
.tableborder th, .tableborder td {
border-collapse: collapse;
border-spacing: 0;
border-right-color: black;
border-right-width: 1px;
border-right-style: solid;
border-bottom-color: black;
border-bottom-width: 1px;
border-bottom-style: solid;
}
Not pretty but it does the job ;-)
Before:
After:
#user538220, you mentioned a simple workaround in your comment, was it something like this, or was it a better solution?
below code worked for me.
table th,td {
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
border-top-width: 0px;
}

Search form (Bootstrap 3) behaving strangely in IE

I have a search form with Bootstrap 3 that looks and works perfectly in Chrome and Firefox, but two of the corners are behaving strangely in Internet Explorer and I can't figure out why. I basically have the input button showing as if it was inside the search form, but in reality the search form has no right borders and the input button has no left borders, so it looks like they're one piece.
For some strange reason I can't figure out, in IE it has both rounded corners and some unfinished straight corners on the right side that looks like this:
Here is my HTML code:
<form class="form-inline topsearchform" role="form">
<div class="input-group">
<input class="form-control searchformradius" type="text" placeholder="Search products...">
<span class="input-group-btn">
<button class="btn btn-default searchformbutton" type="button"><i class="icon-search searchicon"></i></button>
</span>
</div>
</form>
And the CSS:
.searchformbutton{
border-radius: 6px;
border: 1px solid #CCCCCC;
border-left:0px solid #CCCCCC;
height:34px;
}
.searchformbutton:active{
border-radius: 6px;
border: 1px solid #CCCCCC;
border-left:0px solid #CCCCCC;
height:34px;
box-shadow:none;
background: #FFFFFF;
}
.searchformbutton:hover{
border-radius: 6px;
border: 1px solid #CCCCCC;
border-left:0px solid #CCCCCC;
height:34px;
box-shadow:none;
background: #FFFFFF;
}
.searchformbutton:focus{
border-radius: 6px;
border: 1px solid #CCCCCC;
border-left:0px solid #CCCCCC;
height:34px;
box-shadow:none;
background: #FFFFFF;
}
.form-inline.topsearchform{
width:300px;
}
Here is a jsFiddle: http://jsfiddle.net/dpLgc/
Any help as to why it looks like this in IE would be greatly appreciated. Note in the default Bootstrap 3 code, it looks like in IE, so it must be somewhere in this code :(

Centering GWT Elements in UIBinder

I am trying to center a TabLayoutPanel in a uibinder and having no luck whatsoever. As you can see below, I've tried every CSS trick I can think of. Can anyone assist?
<ui:style>
.gwt-TabLayoutPanel {
vertical-align: middle;
text-align: center;
margin-left: auto;
margin-right: auto;
border-top: 1px solid #666;
border-left: 1px solid #999;
border-right: 1px solid #666;
}
</ui:style>
<g:VerticalPanel ui:field="userInterfacePanel" width="100%">
<mapmaker:MapBox ui:field="mapBox"/>
<g:TabLayoutPanel barHeight="20" ui:field="interfaceTabs" height="300px" width="80%" >
<g:tab>
<g:header>Lines</g:header>
<g:Label>Select Line Data Here</g:Label>
</g:tab>
<g:tab>
<g:header>Features</g:header>
<g:Label>Select Features Data Here</g:Label>
</g:tab>
<g:tab>
<g:header>Help</g:header>
<g:Label>Help goes here</g:Label>
</g:tab>
</g:TabLayoutPanel>
<g:HorizontalPanel>
<g:Button>Generate KML</g:Button>
<g:Button>Generate Shapefile</g:Button>
</g:HorizontalPanel>
</g:VerticalPanel>
Centering an item can be done with a cell element like this:
<g:HorizontalPanel width="100%" height="100%">
<g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
<g:Label>Hello Center</g:Label>
</g:cell>
</g:HorizontalPanel>
The problem here is, that .gwt-TabLayoutPanel will not be applied to your TabLayoutPanel. That's because the class names in GWT's UiBinder styles will be obfuscated in the resulting CSS.
There are basically two solutions:
a) Either put your CSS for .gwt-TabLayoutPanel in a plain CSS file. Include that file in your HTML page using
<head>
...
<link type="text/css" rel="stylesheet" href="My.css">
...
</head>
This way, the class name won't be obfuscated.
b) Or (probably better), in the UiBinder <style> section, use an an arbitrary class name like .panel, and change your code like this:
<ui:style>
.panel {
vertical-align: middle;
text-align: center;
margin-left: auto;
margin-right: auto;
border-top: 1px solid #666;
border-left: 1px solid #999;
border-right: 1px solid #666;
}
</ui:style>
...
<g:TabLayoutPanel barHeight="20" ui:field="interfaceTabs"
height="300px" width="80%"
addStyleNames="{style.panel}" >
This way, the class name will be obfuscated both in the style definition, and in the class attribute of your panel.
Now your panel should be centered.
There is another solution exactly for jour case (btw mentioned in javadoc as not recommended for new code).
In View:
interface GlobalResources extends ClientBundle {
#NotStrict
#Source("../resources/css/global.css") //legacy.css
CssResource css();
}
View's constructor:
// Inject global styles.
GWT.<GlobalResources>create(GlobalResources.class).css().ensureInjected();
That way standart CSS can be used without obfuscation.
global.css:
.gwt-DialogBox .Caption {
background: #E3E8F3;
padding: 4px 24px 4px 8px;
cursor: move;
border-bottom: 1px solid #BBB;
border-top: 0px solid white;
text-align: center;
font-family: Georgia, Times New Roman, sans-serif;
}
I injected GlobalResources in main presenter so editing theme for standart widgets (MenuItem,DialogBox,etc.) became much easier.
If the obfuscation of the stylename is the problem as the others suggested simply add:
#external .gwt-TabLayoutPanel;
to the <ui:style> part.

space/gaps between divs on website when viewed on iPhone/iPad

I'm having some difficulty getting my website to display properly when viewed on the iPhone and iPad. The webiste (not even close to being finished) is
www.lzkconcepts.com.
The website displays properly when viewed on every desktop browser I've tried (safari, chrome, firefox, IE), however, on the iPhone/iPad there is a tiny gap/space between the "content" div and header and footer. I'm using a background image in the header, content, and footer divs to create the outline of the page. In addition to the gaps between the divs, the content background image is sometimes "shrunk" a little, so that it doesn't line up with the header and footer on the right side of the screen. If I zoom in though, everything lines up perfectly. Here's a screenshot taken from the iPhone...
http://s1139.photobucket.com/albums/n545/lhkimbrough/?action=view&current=7198e49b.jpg&evt=user_media_share
Look closely at the right side below the blue navigation bar.
Here's the CSS (I know it's very rough, I'm just learning)
#charset "UTF-8";
body {
margin: 0;
padding: 0;
color: #000;
font-family: Arial, Helvetica, sans-serif;
font-size: 100%;
line-height: 1.4;
background-color: #CCC;
}
.TableAppName {
color: #007EB4;
}
/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
padding-right: 15px;
padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
}
/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
color: #42413C;
text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
color: #6E6C64;
text-decoration: underline;
}
#h-navbar {
font-size: 95%;
background-color: #CCC;
background-image: url(images/navBarBlue.png);
background-repeat: no-repeat;
text-align: right;
padding-right: 20px;
color: #FFF;
height: 39px;
padding-top: 6px;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
}
/* ~~ this fixed width container surrounds the other divs ~~ */
.container {
width: 874px; /* the auto value on the sides, coupled with the width, centers the layout */
margin-top: 0;
margin-right: auto;
margin-bottom: 0;
margin-left: auto;
background-color: #CCC;
}
/* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */
.header {
background-color: #CCC;
background-image: url(images/BannerFadedBlueAndOrangeText.png);
background-repeat: no-repeat;
height: 165px;
}
/* ~~ This is the layout information. ~~
1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
*/
.content {
background-color: #CCC;
background-image: url(images/contentFadedDark4.png);
background-repeat: repeat-y;
padding-left: 15px;
}
.contentBottom {
padding: 0px;
margin: 0px;
}
/* ~~ The footer ~~ */
.footer {
background-color: #CCC;
background-image: url(images/FooterFadedDark.png);
background-repeat: no-repeat;
text-align: right;
font-size: 80%;
}
/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
#h-navbar a, #h-navbar a:visited {
text-decoration: none;
color: #FFF;
}
#h-navbar a:hover {
color: #ea6828;
}
.footer p {
color: #0075A7;
}
.content h1 {
color: #0074A9;
font-weight: normal;
font-size: 200%;
font-style: normal;
padding-top: 15px;
padding-left: 23px;
}
.graytext {
color: #333;
}
And here's the HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/LZKConcepts_Template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>LZK Concepts</title>
<!-- InstanceEndEditable -->
<link href="LZKConcepts_styles.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body>
<div class="container">
<div class="header"><!-- end .header --></div>
<div id="h-navbar"> Home | QuickGrader | Wish On A Star | About Us | Contact Us </div>
<!-- InstanceBeginEditable name="MainContent" -->
<div class="content">
<h1>
<!-- end .content -->
iPhone Apps</h1>
<table width="844" border="0">
<tr>
<td width="160" rowspan="2" valign="top"><img src="images/QuickGraderIconReflected140.png" alt="QuickGrader" width="120" height="154" hspace="20" /></td>
<td width="482" class="TableAppName">QuickGrader</td>
<td width="188"> </td>
</tr>
<tr>
<td height="127" valign="top" class="graytext">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris neque quam, facilisis sed iaculis tempor, iaculis vitae purus. Mauris eros lacus, commodo ut feugiat vel, sollicitudin et elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna diam, iaculis ut commodo molestie, congue non lacus. </td>
<td align="right" valign="top"><br />
<img src="images/App_Store_Badge.png" alt="AppStore" width="155" height="54" hspace="18" vspace="0" align="right" /></td>
</tr>
</table>
<p> </p>
<table width="844" border="0">
<tr>
<td width="160" rowspan="2" valign="top"><img src="images/Wish On A Star Reflected.png" alt="QuickGrader" width="120" height="154" hspace="20" /></td>
<td width="482" class="TableAppName">Wish On A Star</td>
<td width="188"> </td>
</tr>
<tr>
<td height="130" valign="top">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris neque quam, facilisis sed iaculis tempor, iaculis vitae purus. Mauris eros lacus, commodo ut feugiat vel, sollicitudin et elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna diam, iaculis ut commodo molestie, congue non lacus. </td>
<td align="right" valign="top"><br />
<img src="images/App_Store_Badge.png" alt="AppStore" width="155" height="54" hspace="18" align="right" /></td>
</tr>
</table>
<p> </p>
<table width="844" border="0">
<tr>
<td width="160" rowspan="2" valign="top"><img src="images/Wish On A Star Free Reflected.png" alt="QuickGrader" width="120" height="154" hspace="20" /></td>
<td width="482" class="TableAppName">Wish On A Star Free</td>
<td width="188"> </td>
</tr>
<tr>
<td height="130" valign="top">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris neque quam, facilisis sed iaculis tempor, iaculis vitae purus. Mauris eros lacus, commodo ut feugiat vel, sollicitudin et elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna diam, iaculis ut commodo molestie, congue non lacus. </td>
<td align="right" valign="top"><br />
<img src="images/App_Store_Badge.png" alt="AppStore" width="155" height="54" hspace="18" align="right" /></td>
</tr>
</table>
</div>
<!-- InstanceEndEditable -->
<div class="footer">
<p><br />
<br />
<br />
Copyright © 2010, LZK Concepts. All rights reserved.</p>
</div>
<!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>
Does anyone have an idea why the iPhone and iPad are rendering the page like this?
On an iPad, when a website is viewed at a scale under 100%, some artefacts appear sometimes. One is particularly visible: a 1 pixel lines between divs, just like on your site, under the menu.
The solution I found is to add a "margin: -1px" between divs. Divs backgrounds overlap with 1 pixel, and if slicing is done accordingly, its invisible for a classic browser, and corrects the problem on the iPad.
Use:
meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"
for when a website is being displayed on a tablet or other device. That should get rid of the pixel difference you see. Sites should be designed semantically scalable these days for maximum cross device access.
As for me, I normally build a php device detecter if there absolutely needs to be a work around.