I have this shape as a PNG that I would like to create it with CSS so that I can dynamically change the fill color.
My question is: How can I most effectively recreate this image using only div
s and CSS?
Note that there is a 5px white stroke around the orange fill. That stroke needs to be created as well. And the area to the right of the curve on the right needs to be transparent. Your CSS can not use external assets such as background images.
Ideally the CSS would work in the majority of browsers including IE 7, 8 and 9. But that's not absolutely required.
Go forth you CSS wizards and show me your darkest dirtiest CSS secrets. I will be putting a bounty of 50 on this as soon as the site allows me, and will award that fully to the best answer, regardless of when you submit you answer.
Let's see what you've got.
To create a circular div in CSS, follow the same steps as above. Add a div in HTML. Then, set the width and height of the element to the same value. Finally, specify the value of the border-radius property to 50%.
The polygon() function is an inbuilt function in CSS which is used with the filter property to create a polygon of images or text. Syntax: polygon( percentage | length); Parameter: This function accepts two parameter percentage or length which is used to hold the value of polygon size.
To create a circle we can set the border-radius on the element. This will create curved corners on the element. If we set it to 50% it will create a circle. If you set a different width and height we will get an oval instead.
HTML
<div id="css"></div>
CSS
#css {
width: 118px;
height: 74px;
margin: 20px 20px;
background: red;
border: 6px solid white;
border-radius: 20% / 62%;
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
Live example
I dare you to guess which one is which without looking at the HTML ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With