简体   繁体   English

在iPad / iPhone上删除CSS Margin

[英]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. 在一个电子商务网站上,我在一个页面上设置了“链接”,该页面具有4个替代产品视图(它们是“添加到购物篮”下面的4个小图像)在iPhone或iPad上,第4个图像的右边距没有删除所以它进入下一行。

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'. 基本上每个图像的右边距为10px,然后最后一个具有“ end”类的图像的右边距为“ 0px!important”。

This works fine in web browsers but on the iPad / iPhone the 0px right margin is not being applied. 这在网络浏览器中工作正常,但在iPad / iPhone上未应用0px右边界。

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. 编辑我添加了下面的代码,并且还设置了我遇到问题的页面的精简版本: link ,它是右侧底部的4个小图像。

Below is the HTML for the images: 以下是图像的HTML:

<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: 这是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. 尝试将:last-child伪元素用于您的移动目标。

.img:last-child {
  margin-right: 0px;
}

Note: It works everywhere except for IE8 and below. 注意:除IE8及以下版本外,它均可在任何地方使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM