Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html button size height percentage

How can I set the button size in HTML to be percentage of screen. Pixel units work but percentage does not. See this fiddle: https://jsfiddle.net/3po5o7cb/10/

<button style="width:20%; height:20%"></button>
<button style="width:200px;height:200px"></button>
like image 212
Hanan Shteingart Avatar asked Jun 08 '26 18:06

Hanan Shteingart


1 Answers

To set a percentage height, its parent element(*) must have an explicit height.

See this answer.

like image 157
fbelanger Avatar answered Jun 10 '26 09:06

fbelanger



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!