4
votes

I am using the Google Material Design Lite CSS library (https://getmdl.io/components/#buttons-section) and I can't seem to change the button size even with inline style.

This is the button I am trying to use:

<button class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect">
    <i class="material-icons">add</i>
</button>

I tried added inline code like this but it's not working:

<button class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect" style="width: 40px; height: 40px"">
  <i class="material-icons">add</i>
</button>

Anyone has any idea how to change the button size in MDL?

2
Inline sizing works for me. jsfiddle.net/addotk1g - Sean Gregory
that style setting of width and height works for me - at.

2 Answers

2
votes

The .mdl-button and .mdl-button--fab classes both have min-width styles, which is why your width of 40px isn't working. You just have to override the min-width style. This code will work:

<button class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect" style="width: 40px; height: 40px; min-width: initial;">
  <i class="material-icons">add</i>
</button>

Of course it's better to separate your styles, like so:

#myButton {
  width: 40px;
  height: 40px;
  min-width: initial;
}
<!-- Load the MDL stylesheet -->
<link href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css" rel="stylesheet"/>

<button id="myButton" class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect">
  <i class="material-icons">add</i>
</button>
0
votes

This works for me.

button.my-button {
width: 47px;
height: 30px;
min-width: initial;
padding: 0px 0px; //give me more space
font-size: 13px;
line-height: 0px; //make text middle vertically
}