我遵循了关于缩放精灵的教程http://tobyj.net/responsive-sprites/ - 当我将图像设置为 100% 时,它们很好,但是当我在媒体查询中使用 35% 的值时,精灵图像是流离失所。
任何想法为什么?我的网站在这里http://edharrisondesign.com/pocketpictograms/
这是我的CSS:
#icon-container {
position: absolute;
top: 50%;
margin-top: -225px;
left: 50%;
width: 400px;
margin-left: -200px;
}
.icon img{
padding-bottom: 150%;
}
/*Set the max-width to the width of your individual sprites:*/
.stretchy { display:block; position:relative; overflow:hidden; width: 100%; max-width:400px; margin: 0 auto; }
.stretchy .spacer { width: 100%; height: auto; }
.stretchy .sprite { position:absolute; top:0; left:0; max-width:none; max-height:100%; }
.stretchy .sprite.s2 {left:-100%;}
.stretchy .sprite.s3 {left:-200%;}
.stretchy .sprite.s4 {left:-300%;}
.stretchy .sprite.s5 {left:-400%;}
.stretchy .sprite.s6 {left:-500%;}
.stretchy .sprite.s7 {left:-600%;}
.stretchy .sprite.s8 {left:-700%;}
.stretchy .sprite.s9 {left:-800%;}
.stretchy .sprite.s10 {left:-900%;}
.stretchy .sprite.s11 {left:-1000%;}
.stretchy .sprite.s12 {left:-1100%;}
.stretchy .sprite.s13 {left:-1200%;}
.stretchy .sprite.s14 {left:-1300%;}
.stretchy .sprite.s15 {left:-1400%;}
.stretchy .sprite.s16 {left:-1500%;}
.stretchy .sprite.s17 {left:-1600%;}
.stretchy .sprite.s18 {left:-1700%;}
.stretchy .sprite.s19 {left:-1800%;}
.stretchy .sprite.s20 {left:-1900%;}
和 HTML:
<div id="icon-container">
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s2" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s3" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s4" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s5" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s6" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s7" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s8" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s9" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s10" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s11" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s12" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s13" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s14" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s15" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s16" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s17" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s18" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s19" alt="" src="images/assets/spritesheet2.png">
</a>
<a class="stretchy">
<img class="spacer" alt="icon" src="images/assets/spacer.png">
<img class="sprite s20" alt="" src="images/assets/spritesheet2.png">
</a>
</div>