【问题标题】:Bootstrap 3: Can the Glyphicons be stacked like Font Awesome's icons?Bootstrap 3:Glyphicons 可以像 Font Awesome 的图标那样堆叠吗?
【发布时间】:2013-10-28 15:20:27
【问题描述】:

是否可以像使用 Font Awesome 的图标一样使用 Bootstrap 来“堆叠”默认字形图标? Glyphicons 可以这样做:http://fortawesome.github.io/Font-Awesome/examples/#stacked 还是我必须进行自定义编码?

谢谢!

【问题讨论】:

    标签: css twitter-bootstrap-3 glyphicons


    【解决方案1】:

    这是一个更短、更简洁的版本(Bass Jobsen 的解决方案)

    css

    .icon-stack {
        position: relative;
    }
    .icon-stack .glyphicon {
        position: absolute; 
    }
    

    html

    <span class="icon-stack">
       <i class="glyphicon glyphicon-unchecked"></i>
       <i class="glyphicon glyphicon-ok"></i>
    </span>
    

    示例

    http://jsfiddle.net/58aED/2/

    【讨论】:

    • 我意识到这已经很老了,但我有一个关于这个答案的简单问题:如果字形大小不同:font-size: 2em,它们会在角落对齐。有没有办法让它们在中心对齐? (例如,将较大的 glyphicon-ban-circle 放在较小的字形图标上)
    • 我会使用边距或填充来完成
    【解决方案2】:

    Bootstrap 的 Glyphicons CSS 没有要堆叠的类。您可以应用示例代码中的类:http://bootply.com/88775

    css

    .icon-stack {
        display: inline-block;
        height: 2em;
        line-height: 2em;
        position: relative;
        vertical-align: -35%;
        width: 2em;
    }
    .icon-stack .icon-stack-base {
        font-size: 2em;
    }
    .icon-stack [class^="icon-"], .icon-stack [class*=" icon-"] {
        display: block;
        font-size: 1em;
        height: 100%;
        line-height: inherit;
        position: absolute;
        text-align: center;
        width: 100%;
    }
    .icon-stack .glyphicon{
        font-size: 2em;
    }
    .glyphicon-ban-circle
    {
        color:red;
    }
    

    html

    <span class="icon-stack">
    <i class="glyphicon glyphicon-phone icon-stack-base"></i>
    <i class="glyphicon glyphicon-ban-circle"></i>
    </span>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-23
      • 2013-09-07
      • 1970-01-01
      • 1970-01-01
      • 2015-07-04
      • 1970-01-01
      • 2013-09-18
      相关资源
      最近更新 更多