我在此处创建了一个博客模板:http://aergaergerg.blogspot.com.au/,正如您所看到的“精选帖子”的按钮为空。我想知道如何通过html小工具本身或css或任何可能的方式向他们添加文本。有些人可能会建议在图片中加入文字,除了我的问题是因为它是'精选文章',显然这些链接会发生很大的变化。下面是想什么,我实现了图片:如何将文本添加到CSS Sprite
总之,这里的HTML的功能后按钮(CSS精灵):
<!--Social Sprite Html2-->
<div id="head-soc2">
<ul>
<li id="Button1"><a href="http://www.spaceheroesfansite.com/p/about.html">3</a> </li>
<li id="Button2"><a href="http://www.spaceheroesfansite.com/p/promo-codes.html"></a> </li>
<li id="Button3"><a href="http://www.spaceheroesfansite.com/p/game-tricks.html"></a></li>
<li id="Button4"><a href="http://www.spaceheroesfansite.com/p/purple-jacket-squad.html"></a></li>
<li id="Button5"><a href="http://www.spaceheroesfansite.com/p/purple-jacket-squad.html"></a></li>
</ul>
<!--Social Sprite Html2--></div>
并为它的CSS:
/*Social Sprite Css Buttons*/
#head-soc2 ul li {list-style :none; padding: 0px; float: center;}
#head-soc2 ul li a {text-indent: -9999px; font-size: 0; line-height: 0; overflow: visible ; border: 0; background: url("http://3.bp.blogspot.com/-D2V1j-OWhrM/UqYsp5RVMuI/AAAAAAAADgI/IsObrayuepI/s1600/bannersprite2.png") no-repeat; display: block;}
#head-soc2 li#Button1 a{background-position: -787px 0px;height: 51px; width: 204px; margin-bottom:15px;}
#head-soc2 li#Button1 a:hover {background-position: -787px -51px;height: 51px; width: 204px}
#head-soc2 li#Button2 a {background-position: -787px 0px;height: 51px; width: 204px; margin-bottom:15px;}
#head-soc2 li#Button2 a:hover {background-position: -787px -51px;height: 51px; width: 204px}
#head-soc2 li#Button3 a {background-position: -787px 0px;height: 51px; width: 204px; margin-bottom:15px;}
#head-soc2 li#Button3 a:hover {background-position: -787px -51px;height: 51px; width: 204px}
#head-soc2 li#Button4 a {background-position: -787px 0px;height: 51px; width: 204px; margin-bottom:15px;}
#head-soc2 li#Button4 a:hover {background-position: -787px -51px;height: 51px; width: 204px}
#head-soc2 li#Button5 a {background-position: -787px -102px;height: 51px; width: 204px; margin-bottom:15px;}
#head-soc2 li#Button5 a:hover {background-position: -787px -102px;height: 51px; width: 204px}
,如果它帮助这里是一个的jsfiddle :) http://jsfiddle.net/8xZDL/
谢谢!
@codehorse这个问题确实有无关精灵,除了这对实现背景图像OP的策略。这更好地描述为“为什么我的文本没有出现在这些按钮中”;答案是,字体大小设置为0,文本缩进9999px离开屏幕。 –