Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border-radius with division

Tags:

html

css

I am having a hard time understanding Mozilla's explanation of the border radius property when division is involved.

Example:

/* (first radius values) / top-left | top-right | bottom-right | bottom-left */
border-radius: 10px 5% / 20px 25em 30px 35em;

I know the first value 10px is the width of the radius and 5% is the height. I don't get how they are affected by the numbers following the /.

One sample: https://jsfiddle.net/wvyesszq/1/

like image 408
Robert Rocha Avatar asked Oct 15 '25 18:10

Robert Rocha


1 Answers

You can give every corner two values (so the maximum are 8 values) which is the radius in two directions (horizontal / vertical).

I think the following pictures explain it perfectly well:

enter image description here

The first set of values define the horizontal radius. And optionally the second set of values, preceded by a ‘/’ (it's not a divison), defines the vertical radius. If only one set of values are supplied, these are used for both the vertical and horizontal radius (what is apparently the reason of the confusion).

So, different from what you assumed – in your example the 10px is the horizontal radius of the top-left-and-bottom-right. And the 5% is the horizontal radius of the top-right-and-bottom-left. And the other four values after '/' are the vertical radii for top-left, top-right, bottom-right and bottom-left.

So remember: On both sites there are shorthands possible (before '/' and after), so you can really have everything between 2 and 8 values).

Check out the documentation of border-radius.

like image 145
ScientiaEtVeritas Avatar answered Oct 17 '25 11:10

ScientiaEtVeritas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!