Let's say we have simple div and his width != height.
<div id="test"></div>
and css looks like:
#test {
width: 200px;
height: 50px;
border-radius: 30%;
border: 5px solid black;
}
The border-radius
in percentage makes longer side more curved. This value in px
would make border equally curved:
#test{
border-radius: 30px;
}
My question is, is there a way (using CSS) to manipulate this proportion in px
(independent from changing div size) and make for example shorter side of div more curved? Or it's only achievable via canvas.
The outline-radius property is used to specify the radius of an outline. It is used to give rounded corners to outlines. This property can only be used in Firefox2-87 (till march 2021) and from Firefox 88, outline-property follows the shape created by border-radius automatically, so this property is no longer needed.
If there are contents within the div that has the curved corners, you have to set overflow: hidden because otherwise the child div's overflow can give the impression that the border-radius isn't working.
The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, or two radii to make elliptical corners.
The only difference between them is the right button has a radius of 5px applied. As with borders, radius allows you to set different properties for each side of the element using the toggle controls.
Writing this question I found the answer: CSS PIE support
It is possible by using slash between values:
border-radius: 10px / 30px;
You can use two values with a slash in between if you want all rounded corners look the same, or you can use selectors for the single corners and use two values without a slash to get independent results for each corner, like border-top-left-radius: 45px 80px;
Here are three examples (I added a symmetric one, similar to the one in your question):
.x {
width: 300px;
height: 200px;
border: 2px solid green;
border-radius: 45px / 80px;
}
.y {
width: 300px;
height: 200px;
margin-top: 30px;
border: 2px solid red;
border-top-left-radius: 45px 80px;
border-top-right-radius: 125px 60px;
}
.z {
width: 300px;
height: 100px;
margin-top: 30px;
border: 2px solid blue;
border-top-left-radius: 80px 65px;
border-bottom-left-radius: 80px 65px;
border-top-right-radius: 80px 65px;
border-bottom-right-radius: 80px 65px;
}
<div class="x"></div>
<div class="y"></div>
<div class="z"></div>
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