Home > Web Front-end > CSS Tutorial > How to Create Irregularly Shaped Div Borders with CSS?

How to Create Irregularly Shaped Div Borders with CSS?

Mary-Kate Olsen
Release: 2024-12-18 13:59:10
Original
307 people have browsed it

How to Create Irregularly Shaped Div Borders with CSS?

Customizing Div Border Radii for Irregular Curves

Question:

How can you achieve uneven rounded sides on a div that deviate from the typical border-radius shape?

Solution:

While border-radius allows for rounded corners, creating irregular curves requires a different approach. Here's a solution using CSS clip-path:

.box {
  height: 200px;
  width: 200px;
  background: blue;
  clip-path: circle(75% at 65% 10%);  // Customize the shape here
}
Copy after login

The clip-path property employs a circular function to define the shape of the clipping region. This allows you to specify the percentage and position of the circle, resulting in an unevenly rounded div. In the provided example:

  • circle(75%): Defines the radius of the circle as 75% of the div's size.
  • at 65% 10%: Positions the center of the circle at 65% on the horizontal axis and 10% on the vertical axis.

By adjusting these parameters, you can create unique and complex div shapes.

The above is the detailed content of How to Create Irregularly Shaped Div Borders with CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template