由于某种原因,我的实时网站上的图像(来自精灵表)与本地版本的位置不同。这让我疯狂!在检查元素时,似乎精灵表在活动时的缩放比例略有不同,这使图像比我想要的更右移动。任何想法为什么?
提前谢谢了!
的HTML:
<div id="icon-container">
<div class="icon">
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s2" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s3" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s4" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s5" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s6" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s7" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s8" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s9" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s10" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s11" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s12" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s13" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s14" alt="" src="images/assets/spritesheet.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s15" alt="" src="images/assets/spritesheet.png">
</a>
</div>
</div>
CSS:
.stretchy {display:block; position:relative; overflow:hidden; max-width:400px; }
.stretchy .spacer { width: 100%; height: auto; }
.stretchy .sprite {
position:absolute; top:-5px; left:0; max-width:none; max-height:100%;
}
.stretch img { width: 100%; }
.stretchy .sprite.s2 {left:-103%;}
.stretchy .sprite.s3 {left:-205%;}
.stretchy .sprite.s4 {left:-307%;}
.stretchy .sprite.s5 {left:-407%;}
.stretchy .sprite.s6 {left:-508%;}
.stretchy .sprite.s7 {left:-608%;}
.stretchy .sprite.s8 {left:-709%;}
.stretchy .sprite.s9 {left:-811%;}
.stretchy .sprite.s10 {left:-911%;}
.stretchy .sprite.s11 {left:-1012%;}
.stretchy .sprite.s12 {left:-1113%;}
.stretchy .sprite.s13 {left:-1216%;}
.stretchy .sprite.s14 {left:-1318%;}
.stretchy .sprite.s15 {left:-1418%;}