调整垫子凸起按钮的大小

时间:2019-08-02 15:31:56

标签: html css

我正在尝试减小垫高按钮的尺寸。我以为我可以通过减小文本的大小来减小按钮的大小。但是我无法这样做。

这是CSS:

button {
    margin-right: 1vw;
    background: #4285F4;
    color: white;
    font-size: 9px;
    height: auto;
    width: auto;
}

和模板:

<button mat-raised-button class="button"><span>Click here to submit</span></button>

5 个答案:

答案 0 :(得分:5)

您在正确的轨道上。除了字体大小,您还需要更改行高:

button{
    margin-right: 1vw;
    background: #4285F4;
    color: white;
    font-size: 9px;
    line-height: 18px;
    height: auto;
    width: auto;
}

https://stackblitz.com/edit/angular-fmgfn1

答案 1 :(得分:0)

width: auto;更改为指定的单位,例如pxemrem

例如,将宽度更改为200px

button {
    margin-right: 1vw;
    background: #4285F4;
    color: white;
    font-size: 9px;
    height: auto;
    width: 200px; 
}

答案 2 :(得分:0)

尝试使用类而非元素进行控制,并更改大小,例如本例

.button {
margin-right: 1vw;
background: #4285F4;
color: white;
font-size: 9px;
height: 70px;
width: auto;}

答案 3 :(得分:0)

我已经测试过,除非您使用!important css声明(需要覆盖该材料的css声明),否则它在Chrome中不起作用。按钮将很好地缩放。这些值取决于您的个人需求,您必须对其进行调整。

    .varButton {
      margin-right: 1vw !important;
      font-size: 2.7vw !important;
      line-height: 3vw !important;
    }

    <button mat-raised-button type="submit" class="varButton">

答案 4 :(得分:0)

Mat-raised-buttonwidthmin-width 都设置为 64px,您需要在按钮 CSS 样式表中覆盖它们。