CSS Round Radis
In the Web development,
border-radius
Properties have evolved from simple rounded buttons to a central tool for building complex shapes and modern UIs.
1. Basic grammar: more than just four corners
Although most people are used to it.
border-radius: 8px;
This shorthand, but CSS actually allows us to define a different radius for each angle.
- Single value: The four angles have the same radius.
- Polyvalue: Sets in the order of " Top Left, Top Right, Bottom Right, Bottom Left " .
-
Slash syntax:
Horizontal Radius / Vertical Radius。 This is the key to creating irregular shapes (e.g. ellipse or organic shapes).
2. Common design scenarios and solutions
Scenario one: Create a perfect circle
When the element is equal in width (square) and the corner is set to
50%
or larger, the element will be in a positive circle. This is often used in user headers.
Scenario 2: Modernly-sensed "Putting pills" button
For rectangular buttons, you can get smooth half-rounded ends by setting the corner value to more than half the height.
Scenario III: Organic "liquid" shape
Controls the horizontal and vertical radiuss of each angle independently, e.g.
60% 40% 30% 70% / 60% 30% 70% 40%
, which creates organic shapes that seem very natural and asymmetric.
3. Browser compatibility and performance
border-radius
It is extremely well supported in all modern browsers. From a performance point of view, it is much more efficient than using background pictures to achieve round corners, as it is directly processed by the browser ' s rendering engine to support hardware acceleration.
Use ours. Visualized CSS round corner generator , you can drag sliders in a visual way, observe shape changes in real time and copy the generated standard CSS code directly to your project.