Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a button to span the width of the card that it is contained in?

I'm using Angular v6 and Angular Material to build a front page for a web project. I was wondering, how can I have the width of the button stretch to match the width of the material card component that it appears in?

Here's my code:

<div style="padding:5px">
  <mat-card>
    <button mat-button style="background-color: #008CBA; width:100%;">Portfolio</button>
    <button mat-button style="background-color: #008CBA; width:100%;">Portfolio</button>
    <button mat-button style="background-color: #008CBA; width:100%;">Portfolio</button>
  </mat-card>
</div>
like image 699
DoubleDurian Avatar asked Oct 29 '25 07:10

DoubleDurian


1 Answers

For something like this, normally adding:

style="width: 100%; display: block;"

in the button would stretch it. If that doesn't work, go into inspect element of the button and make sure that max-width isn't set to anything lower than 100% (try display: flex as well).

Please give an example of your code for a more specific answer.

like image 162
Armin Z Avatar answered Oct 30 '25 23:10

Armin Z



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!