Home  >  Article  >  Web Front-end  >  How Can I Create Inverted Scooped Corners in CSS Using Only CSS?

How Can I Create Inverted Scooped Corners in CSS Using Only CSS?

Linda Hamilton
Linda HamiltonOriginal
2024-11-19 14:52:03412browse

How Can I Create Inverted Scooped Corners in CSS Using Only CSS?

Creating Inverted Scooped Corners Using Pure CSS

In CSS, creating rounded corners is straightforward using the border-radius property. However, achieving inverted scooped corners, where the corners curve inward, requires a more advanced technique.

To create inverted scooped corners, we'll employ the following approach:

  • Create a transparent square with hidden overflow.
  • Place a transparent circle with a box shadow inside the square.
  • Adjust the position of the circle to reveal only a quarter of it.

Code Implementation

#box {
  position: relative;
  width: 200px;
  height: 50px;
  background-color: blue;
  border-radius: 9999px 0 0 9999px;
  margin: 30px;
  text-align: center;
  color: #fff;
  padding-top: 10px;
}

#top,
#bottom {
  position: absolute;
  height: 30px;
  width: 30px;
  right: 0;
  overflow: hidden;
}

#top {
  top: -30px;
}

#bottom {
  bottom: -30px;
}

#top::before,
#bottom::before {
  content: '';
  position: absolute;
  right: 0;
  height: 200%;
  width: 200%;
  border-radius: 100%;
  box-shadow: 10px 10px 5px 100px blue;
  z-index: -1;
}

#top::before {
  top: -100%;
}

The above is the detailed content of How Can I Create Inverted Scooped Corners in CSS Using Only CSS?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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