CSS Curvy Background

03/02/2021

Contents

Demo

Full Screen

Code

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Curvy Background</title>
    <link rel="stylesheet" type="text/css" href="https://demo.plantpot.works/assets/css/normalize.css">
    <link rel="stylesheet" href="https://use.typekit.net/opg3wle.css">
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <div id="container">
      <section>
        <h1>CSS Curvy<br>Background</h1>
      </section>
    </div>
  </body>
</html>

CSS

@charset "utf-8";
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
}
body {
  background-color: #f3f3e9;
  font-family: futura-pt, sans-serif;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}
#container {
  position: relative;
  width: 100%;
  height: 100vh;
}
section {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 80vh;
  overflow: hidden;
}
section::before {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  transform: scaleX(1.6);
  border-radius: 0 0 100% 100%;
  background: #421ff2;
  content: '';
}
h1 {
  z-index: 10;
  margin: 0;
  color: #fff;
  font-size: 4rem;
  letter-spacing: 5px;
  text-align: center;
}
@media screen and (max-width: 480px) {
  h1 {
    font-size: 2.5rem;
    letter-spacing: 2px;
  }
}