Home >Web Front-end >CSS Tutorial >How Can I Create a Wavy Shape Using CSS?

How Can I Create a Wavy Shape Using CSS?

DDD
DDDOriginal
2024-12-18 01:51:09364browse

How Can I Create a Wavy Shape Using CSS?

Creating Wavy Shapes with CSS

Question:

How can I create a wavy shape like this image using CSS?

[Image of a Wavy Shape]

Initial Attempt:

This CSS creates a straight line:

#wave {
  position: absolute;
  height: 70px;
  width: 600px;
  background: #e0efe3;
}

Answer:

To achieve a wavy shape, we can leverage SVG paths. By combining a container with responsive properties and an SVG with a curved path, we can create the desired effect:

svg {
  display: inline-block;
  position: absolute;
  top: 0;
  left: 0;
}
.container {
  display: inline-block;
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  vertical-align: middle;
  overflow: hidden;
}
<div class="container">
  <svg viewBox="0 0 500 500" preserveAspectRatio="xMinYMin meet">
    <path d="M0,100 C150,200 350,0 500,100 L500,00 L0,0 Z">

The above is the detailed content of How Can I Create a Wavy Shape Using 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