Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Border Radius Second Radius Explanation

Tags:

css

I was reading the docs at https://developer.mozilla.org/en/docs/Web/CSS/border-radius

The border radius attribute seems to have a second radius value,

/* The syntax of the second radius allows one to four values */
/* (first radius values) / radius */
border-radius: 10px 5% / 20px;

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

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

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

I am aware of the border radius attribute and it's short syntax but I don't understand what does the values after '/' do.

like image 247
Seif Sayed Avatar asked Mar 18 '17 20:03

Seif Sayed


People also ask

How do four values work on border radius?

CSS Syntax Note: The four values for each radius are given in the order top-left, top-right, bottom-right, bottom-left. If bottom-left is omitted it is the same as top-right. If bottom-right is omitted it is the same as top-left. If top-right is omitted it is the same as top-left.

What is the difference between border and border radius?

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.

What does border radius do in CSS?

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.

How do you calculate border radius in CSS?

The border radius of the outer element should be equal to the sum of the border radius of the inner element and the distance between the two elements. This can be mathematically expressed as innerRadius + distance = outerRadius or more tersely R1 + D = R2 .


1 Answers

The first set of values defines the horizontal radius. The optional second set of values, preceded by a ‘/’ , defines the vertical radius. If only one set of values is supplied, it is used for both the vertical and horizontal radius.

like image 186
Seif Sayed Avatar answered Sep 28 '22 04:09

Seif Sayed