>  기사  >  웹 프론트엔드  >  css笔记--小图标文字对齐中级解决方案_html/css_WEB-ITnose

css笔记--小图标文字对齐中级解决方案_html/css_WEB-ITnose

WBOY
WBOY원래의
2016-06-24 11:22:511156검색

出处:http://www.zhangxinxu.com/study/201603/icon-text-vertical-align.html

css

.icon {     display: inline-block;     width:20px; height:20px;     background: url(delete.png) no-repeat center;     white-space:nowrap;     letter-spacing: -1em;     text-indent: -99em;     color: transparent;    /* IE7 */    *text-indent: 0;    *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '\3000');}.icon:before {     content: '\3000'; }

html

<strong>情形1,空标签</strong><p><i class="icon"></i> 删除</p><strong>情形2,内部有文字</strong><p><a href="javascript:" class="icon">删除</a> 后面的文字</p><p style="color:gray;">--------下面是反例------</p><strong>设置了overflow:hidden</strong><p><i class="icon" style="overflow:hidden;"></i> 删除</p>

 

效果图1 小字号

  

 

2 大字号

 

  

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.