例如:
HTML代码
<div>
<h1><span class="title-icon">icon</span> Hello India!</h1>
</div>CSS代码
h1{
}
h1 span{
background: url("../images/icon.png")
text-indent: -9999px;
width:24px;
height:24px;
margin-right:1em;
}发布于 2013-08-09 18:52:43
text-indent不能在inline元素上工作。<span>默认为inline。您需要更改它,使其作为内联块工作:
display:inline-block;发布于 2013-08-09 18:56:37
尝试将font-size设置为zero
h1 span {
background: url("../images/icon.png")
font-size: 0;
width: 24px;
height: 24px;
margin-right: 1em;
}发布于 2015-04-23 03:21:43
我的问题是文本对齐。如果您修改了元素的对齐模式或将其向左换行的父元素,则必须为text-indent指定负索引。否则,您必须提供一个正值。
.case1{text-indent:-999px;text-align:left;overflow:hidden;display:block}否则
.case2{text-indent:999px;text-align:right;overflow:hidden;display:block}https://stackoverflow.com/questions/18144991
复制相似问题