I was wondering if you can help me with this. I have a div (in white) where I need to put two round buttons (in green) on the borders. Everything needs to be done using CSS. It should look like this: Screenshot
Now the thing is, I don’t know the size of the white div, and I won’t know it at the time of creation, because after that it will be added to the DOM. All I know is that the white div has a percentage width and height relative to the future parent. Thus, at creation time, since it has not been added yet, any calls to width (), height () or its css values will not work. I saw all these snippets that tell you how to make a div with a fixed aspect ratio. I need it now, I need the button to be 1: 1, but all I know about the dimensions is that it should be 100% of the height of the white div (and therefore its width should be equal to its height). All the examples I've seen assume that you know the width and that the height maintains the ratio. In my case, what I know is height (100%), and I want the width to be adapted. I do not know how to achieve this.
This is my snippet:
body{ background-color: #DCDCDC; } .container { width: 50%; height: 7%; background: white; border-radius: 20px; position: absolute; } .arrow { background: green; border-radius: 20px; height: 100%; position: absolute; } .arrow:after{ content: ""; display: block; padding-right: 100%; } .arrow:last-child { right: 0; }
<div class="container"> <div class="arrow"></div> <div class="arrow"></div> </div>
https://jsfiddle.net/7bxecL9m/
If you know how I can do this without entering a fixed value (using jQuery, of course, really), I would really appreciate it.
Thanks.
javascript jquery html css css3
Pablo grabarnik
source share