代码之家  ›  专栏  ›  技术社区  ›  stone rock

如何减小mdbootstrap中按钮的大小?

  •  0
  • stone rock  · 技术社区  · 6 年前

    我想减小按钮的默认大小,但只有字体大小减小。我想按比例减小字体大小和按钮大小。

    我尝试减小字体按钮,但大小与字体不成比例。

    参考链接: https://mdbootstrap.com/components/buttons/

    代码:

    HTML:。

    <div class=“standings”>
    <DIV class=“StandingsTitle”>
    <h4>团队排名</h4>
    <button type=“button”class=“btn btn danger”>查看所有统计信息</button>
    </DIV>
    </DIV>
    

    CSS:。

    .btn危险{
    字体大小:6px;
    宽度:25px;
    高度:30px;
    }
    

    屏幕截图:(按钮的默认大小):。

    在尝试了以上代码之后,给了我:

    .

    参考链接:https://mdbootstrap.com/components/buttons/

    代码:

    HTML:

    <div class="standings">
        <div class="standingstitle">
            <h4>Teams Standings</h4>
            <button type="button" class="btn btn-danger">See all stats</button> 
        </div>
    </div>
    

    CSS:

    .btn-danger{
        font-size: 6px;
        width: 25px;
        height: 30px;
    }
    

    屏幕截图:(按钮的默认大小):

    enter image description here

    在尝试了以上代码之后,我得到了:

    2 回复  |  直到 6 年前
        1
  •  1
  •   Aryan Twanju    6 年前

    你需要调整 padding 默认情况下的属性 btn 选择器。尝试此代码。

    .btn {
        padding: .4rem 1.5rem;
    }
    
        2
  •  0
  •   Fabian N.    6 年前

    尝试使选择器更具体,以防止覆盖规则:

    btn btn-sm btn-danger {
        font-size: 6px;
        width: 25px;
        height: 30px;
    }