How to Create Wave Background using CSS ?

The wave background can be easily generated by using before selector. We will use a wave image of .png file format which you can create on your own or can download from here.

HTML Code: In this section, we will design the basic structute of the code.



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0" />
          
    <title>
        How to Create Wave Background using CSS ?
    </title>
</head>
  
<body>
    <section class="pattern">
        <div class="geeks">
            <h1>GEEKS FOR GEEKS</h1>
        </div>
    </section>
</body>
  
</html>

chevron_right


CSS code: In this section, we will use some CSS property to design the wave background. First we will add a basic background to the section and then use the before selector to set the wave png file on top of our background.

filter_none

edit
close

play_arrow

link
brightness_4
code

<style>
    body {
        padding: 0%;
        margin: 0%;
    }
    .geeks {
        padding: 200px;
        text-align: center;
    }
       
    section {
        width: 100%;
        min-height: 500px;
    }
       
    .pattern {
        position: relative;
        background-color: #3bb78f;
        background-image: linear-gradient(315deg,
                        #3bb78f 0%, #0bab64 74%);
    }
       
    .pattern:before {
        content: "";
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 215px;
        background: url(wave.png);
        background-size: cover;
        background-repeat: no-repeat;
    }
</style>

chevron_right


Complete code: It is the combination of the above two code section.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0" />
  
    <title>
        How to Create Wave Background using CSS ?
    </title>
  
    <style>
        body {
            padding: 0%;
            margin: 0%;
        }
  
        .geeks {
            padding: 200px;
            text-align: center;
        }
  
        section {
            width: 100%;
            min-height: 300px;
        }
  
        .pattern {
            position: relative;
            background-color: #3bb78f;
            background-image: linear-gradient(315deg,
                    #3bb78f 0%, #0bab64 74%);
        }
  
        .pattern:before {
            content: "";
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 250px;
            background: url(
            background-size: cover;
            background-repeat: no-repeat;
        }
    </style>
</head>
  
<body>
    <section class="pattern">
        <div class="geeks">
            <h1>GEEKS FOR GEEKS</h1>
        </div>
    </section>
</body>
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.