I'm writing an app with Angular 8 and NativeScript 6.4.1.
I want to create a perfectly square button. I'm not able to hard-code the height and width.
e.g. height: 20px width: 20px
is not good for me because my app will run on different devices with different screen sizes.
I have tried these suggestions:
https://spin.atomicobject.com/2015/07/14/css-responsive-square/
https://dev.to/tchaflich/a-width-responsive-perfect-square-in-pure-css-3dao
It doesn't seem to work for me.
Here is my playground:
https://play.nativescript.org/?template=play-ng&id=j8Gsd1&v=3
How can I make perfectly square buttons?
code snippet:
.sqaure-button {
height: 40%;
width: 40%;
}
.sqaure-button:after {
content: "";
display: block;
padding-bottom: 100%;
}
<Button class="sqaure-button" backgroundColor="pink"></Button>
This image is the desired result in terms of the square sizes and the device size: