目前,我所有的css精灵都是垂直对齐的,格式不正确。我该如何水平对齐它们?这是我的一个按钮的例子:
a.youtube {
background: url(images/icons.png) no-repeat 0 0;
height: 64px;
width: 64px;
display: block;
background-position: 0 -128px;
}
a.youtube:hover {
background-position: -64px -128px;
}我现在不能使用以下命令将它们与中心对齐:
#social_cont {
text-align: center;
background: url(images/banners/banner1.jpg);
height: 254px;
}和这个html:
<div id="social">
<a class="facebook" href="http://facebook.com/projectstratos"></a><a class="twitter" href="http://twitter.com/projectstratos"></a>
</div>发布于 2011-03-05 21:37:53
你可以先看看这个:
如果对您不起作用,请手动定位:
发布于 2011-03-05 21:58:32
如果希望链接图标水平对齐,请将float:left添加到a.youtube的CSS声明中。至于居中,您只需确保您的sprite被设计为精确地适合64x64像素的容器。(这里不能使用background-position:center center;,因为它会在容器中居中显示整个背景图像)。
https://stackoverflow.com/questions/5203939
复制相似问题