Positioning a background image from the right rather than left - background-image

Is it possible to specify that you want a background image (non-repeating) to sit, say, 5px away from the RIGHT edge?
I know it's possible to do this with CSS, but it defaults to the LEFT edge. I'd like the background image to always sit 5px away from the right edge instead.
CSS
#companyLinks li {
display: inline;
padding-right: 10px;
background-image: url(/img/shd/spacer.png);
background-repeat: no-repeat;
background-position: right center;

#Francesca
Instead writing 3 lines to define background you can use below one line code, which will serves your purpose...
background: url(/img/shd/spacer.png) no-repeat top right;
OR if you want it fix the position in Center then, you can use
background: url(/img/shd/spacer.png) no-repeat fixed right;
You're using two Positioning value, i.e. Center & Right which is creating conflict.
You can use one value for horizontal & one for vertical at a time.

You can always edit the image to give you 5px of alpha-transparent spacing on the right, and then use:
background: url(/img/shd/spacer.png) no-repeat fixed right;
As suggested in Hignesh's answer.
I know it sounds like a hack, but that should certainly work. Either that or specifying a container div of a fixed width, and placing an inner div of (parent width - 5px), and make sure it's pinned to the left side, with the image to the right as designated by the above CSS.

background-position: right 5px center;
or
background: url(/img/shd/spacer.png) no-repeat fixed right 5px;

try using this table instead I think this should work according to your need :P
<table border="2" align="center" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tr height="100%">
<td style="background-image:url('http://www.dvd-ppt-slideshow.com/images/ppt-background/background-31.jpg'); background-position:right; background-repeat:no-repeat; " height="100%" ></td>
<td style="width: 10px;"></td>
</tr>
</table>

Related

Align center with media queries (EMAIL CODE)

This is email code, hence using tables instead of using lists.
If I change the width of the promo_1-3 to be a fixed number (say 300px) I can get them to align left and right (like the original code at the desktop size) but I can't get them to ignore the originally specified left or right alignment and be centered
#media only screen and ( max-width: 660px) {
table.container { width: 100% !important; }
td.logo img { width:100% !important; }
td.headerimg img{ width: 100% !important; padding: 5px 30px 40px 30px;}
td.promos table.promo_1 { width: 100% !important; }
td.promos table.promo_1 td { padding: 20px 20px 40px 30px; }
td.promos table.promo_2 { width: 100% !important; }
td.promos table.promo_2 td { padding: 20px 0px 40px 30px; }
td.promos table.promo_3 { width: 100% !important; border-top: 1px solid #CAC5C5; }
td.promos table.promo_3 td { padding: 20px 0px 40px 30px; }
Here's the HTML:
<!-- Start story 1 -->
<tr>
<td valign="top" bgcolor="#fff" class="promos" style="padding: 10px 10px 20px 20px; background-color: #fff; font-family: Arial, Helvetica, sans-serif;">
<table class="promo_3" width="300" align="left">
<tr>
<td>
<a target="_blank" href="http://trailrunnermag.com/training/training-plans/1860-what-your-weekly-training-plan-should-look-like">
<img class="promo" alt="Promo image 1" src= "http://media.campaigner.com/media/47/474810/063016ID3.jpg"></a>
<h3 style="font-size:16px;">Promo heading here</h3>
<br><br>
Learn more
</td>
</tr>
</table>
If i understand your question correctly here is the fix:
in your HTML change the line:
<table class="promo_3" width="300" align="left">
to
<table width="300" class="promo_3" align="left">
so it applys the class specified atributes after you set the width.
This makes you table then be 100% wide on a smaller screen.
Then change your css line like this:
td.promos table.promo_3 { width: 100% !important; border-top: 1px solid #CAC5C5; }
to
td.promos table.promo_3 { width: 100% !important; text-align: center; border-top: 1px solid #CAC5C5; }
to align the Content in your table to the center.
Also, if you are using this for an Email, I'd recomend you to not use the H3 because it always gives trouble, since every client interprets it a littble bit different. Instead use a span and apply styles to it.

How to add retina image to responsive email

Logo image is doubled and reduced to smaller size with set pixel width and height. I want the image cleaner and not blurry. Logo still is original size in outlook.
Do I need to wrap this in it's own table to a set pixel width?
Do I need to set a certain class to it?
How can I clean up this code to work more efficiently?
<td bgcolor="#FFFFFF" width="150" align="center" target="_blank"><img src="http://..t_lgo-300.jpg" width="150px" height="89px" alt="" style="display: block; border: 0; font-family: 'Open Sans', Arial, sans-serif; color: #86898B; font-style: normal; font-size: 18px; line-height:10px; width: 150px; height: 89px;"></td>
styles - the logo does not have a class....
td[class="logo"] img{
margin:0 auto!important;
}
img[class="img-max"]{
max-width: 100% !important;
width: 100% !important;
height:auto !important;
}
I don't believe it is necessarily the code so much as it is the quality of the image. (https://www.emailonacid.com/blog/article/email-development/mobile-optimization-retina-images-in-email)
For retina images it is best to save the image as double if not triple the size of what you want in your message (at a high resolution). Ex. save at 300x150 for 100x50 image in email.
Just make sure to declare your width and height on image tag or Outlook will display the raw image size. You can then use media queries to set it to the proper size for mobile display.

Accordion is not expanding div

Browser: ie11 (My company requires this).
Once expanded, it overflows the div and the footer.
I need it to extend the div behind it so it always fits.
Currently, the div behind has these attributes:
height:600px;
width:650px;
background-color:white;
margin-left:200px;
margin-top:-520px;
position:absolute;
z-index:10;
border-radius:50px 10px 50px 10px;
border:solid;
border-width: 5 5px;
border-color: #fcf17a;
box-shadow:5px 5px 12px black;
font-size: 12px;
I am also using the Vallenato accordion as I'm not too good with JS myself.
Found here:
http://www.switchroyale.com/vallenato/
Image of accordion here
http://i.imgur.com/0mCCeX6.png
Thanks for your time.

Seamless scaling of website header on the iphone.

I have a website (http://ukchina-trading.com/) with the following header:
HTML
<div class='leftImage'>
<img src='image/unionjack.png'>
</div>
<div class='title'>
<h1>J Plus Trading</h1>
<h2>Briding the gap between China and the UK</h2>
</div>
<div class='rightImage'>
<img src='image/chinawings.png'>
</div>
CSS
.title h1 {
font-family: 'Droid Serif', Georgia, Times, serif;
text-align: center;
font-size: 68px;
line-height: 65px;
padding-top: 60px;
margin-bottom: 80px;
}
.title h2 {
font-family: 'Droid Serif', Georgia, Times, serif;
text-align: center;
position:relative;
top:-88px;
left:3px;
font-size: 16px;
color: #FF3300;
}
.rightImage {
position:absolute;
right: 150px;
top: 2px;
}
.leftImage {
position:absolute;
left: 150px;
top: 2px;
}
When the website is view on a computer the header is fine, but when viewed on the iphone screen the images are pushed over the title, hiding it.
What is the best way to redo the header to stop this?
I'd suggest the best thing to do would be to bring the flags inside the 900px width of the website.
Keep them to the left and right of the "J Plus Trading" text but just use floats rather than absolute positioning.
your problem is the absolute positioning you are using, as this causes the images to be in the same position regardless of anything else on the page. instead of absolute try using float:left; and float:right on your left and right images, and this way the text will not be pushed over it. you may have to create extra containing divs with margins or padding so that the images are positioned how you want them

Removing CSS Margin on iPad / iPhone

On an e-commerce website that I set-up Link on a page that has 4 alternative product views (they are the 4 small images underneath the add to basket) On an iPhone or iPad the 4th image isn't having its right margin removed so it goes onto the next line.
Basically each images has a 10px right margin, and then the last image that has a class of 'end' has a right margin of '0px !important'.
This works fine in web browsers but on the iPad / iPhone the 0px right margin is not being applied.
I have a feeling this is going to be an easy one but I just can't see it, thanks in advance for any help.
EDIT I have added the code below and have also set-up a stripped down version of the page I am having the problems on: link, it is the 4 small images at the bottom of the right hand side.
Below is the HTML for the images:
<div class="image-additional">
<img alt="" title="" src="larchblue-cr-55x55.jpg" class="thumb ">
<img alt="" title="" src="larchgreen-cr-55x55.jpg" class="thumb ">
<img alt="" title="" src="larchpink-cr-55x55.jpg" class="thumb ">
<img alt="" title="" src="larchyellow-cr-55x55.jpg" class="thumb end">
</div>
And here is the CSS:
.image-additional {
width: 268px;
margin-top: 13px;
clear: both;
position: absolute;
bottom: 0;
overflow: hidden;
}
.image-additional img {
border: 1px solid #E7E7E7;
margin-right: 10px;
}
.image-additional img.end, .image-additional img:last-child {
margin-right: 0px !important;
}
Try using :last-child pseudo element for your mobile targets.
.img:last-child {
margin-right: 0px;
}
Note: It works everywhere except for IE8 and below.