zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    CSS选择器
    CSS样式与语法
    实训第二天
    初学前端
    html-路径和图像标签
    html
    JavaScript(基础)
    CSS(2)
    CSS()
    HTML(链接与表单)
  • 原文地址:https://www.cnblogs.com/myspecialzone/p/5973033.html
Copyright © 2011-2022 走看看