代码之家  ›  专栏  ›  技术社区  ›  SaidbakR

引导3按钮图标,左边有边框

  •  4
  • SaidbakR  · 技术社区  · 7 年前

    填充整个高度

    我尝试了以下CSS:

    a.btn.btn-xlg i {
        float: left;
        border-right: groove;
        height: 100%;
        display: inline-block;
        padding: 0 4%;
    }
    

    HTML是:

    ...
    <a href="/job" class="btn btn-xlg btn-olive center-block"><i class="fox-job"></i>Jobs</a>
    ...
    

    以下是我获得的屏幕截图:

    enter image description here

    [class^="fox-"]:before, [class*=" fox-"]:before {
        font-family: "fox";
        font-style: normal;
        font-weight: normal;
        speak: none;
        display: inline-block;
        text-decoration: inherit;
        width: 1em;
        margin-right: .2em;
        text-align: center;
        /* opacity: .8; */
        font-variant: normal;
        text-transform: none;
        line-height: 1em;
        margin-left: .2em;
        font-size: 140%;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-shadow: 0px 1px 5px rgba(255, 207, 118, 0.9);
    }
    

    有没有办法让边框覆盖屏幕截图中所示的按钮的整个高度?

    更新2:

    根据加森·楼海池的回答,我得到了屏幕截图: enter image description here

    我使用了以下CSS:

    a.btn.btn-xlg i {
        float: left;
        border-right: groove;
        /* height: 100%; */
        display: inline-block;
        /* padding: 20px 16px; */
        height: 72px;
        padding: 20px 5px 0 0;
        margin-top: -20px;
        margin-bottom: -26px;
    }
    
    1 回复  |  直到 4 年前
        1
  •  2
  •   Ghassen Louhaichi    7 年前

    按钮中有一个填充,您需要手动删除并将按钮的内容放置在垂直中心,或者将以下CSS规则添加到类中,以使用负边距来抵消填充的影响(您可能需要稍微调整该值,直到它看起来正确):

    a.btn.btn-xlg i {
        /* the other attributes... */
    
        /* set the icon height to the button height */
        height: 34px;
        /* pad the icon to be at the center instead of the top */
        padding: 9px 4%;
        /* adjust the negative margins to counter the padding effect */
        margin-top: -8px;
        margin-bottom: -6px;
    }