I'm trying to make something like this in HTML/CSS: https://gyazo.com/6db0d2e3565414c10b65480c5d4b7526
I'm using a bootstrap template which I want to make this work with. My best try so far is the following piece of code:
<td class="tablerow mdl-data-table__cell--non-numeric"
style="background-color:red;padding:0 !important">
<div class="circlediv" style="background-color:green;
border-radius: 100%;
height:100%;">
</div>
</td>
Which gives me this: https://gyazo.com/dab11409ae41f9deb69418d10d74d2c5
How can I make this a perfect circle, no matter what the lengths of the sides of the outer div are?
Edit
The problem is that the width and height of the outer td
gets calculated at run-time by javascript by my template. Sometimes its 20px, other times its 50px for example, depending on the users screen. I need to have a circle, that always stays circular (maintaining aspect-ratio) no matter what the dimensions of the td
are.
Edit #2
I figured this would be possible with css but it doesn't seem to be. Thanks to Bagzli's answer I made it simple using the following snippet:
<script type="text/javascript">
$('.circlediv').width($('.circlediv').height())
</script>