CSS Skewed Background

Web Design & Web Development

Demo

Sponsored links

 

Code

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Skewed 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 class="skewed-bg">
        <div class="box">
          <h1>Skewed Background</h1>
        </div>
      </section>
    </div>
  </body>
</html>

CSS

@charset "utf-8";
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
}
body {
  font-family: futura-pt, sans-serif;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}
#container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
  height: 100vh;
  background-color: #921944;
}
.skewed-bg {
  display: flex;
  justify-content: center;
  align-items: center;
  transform: skewY(-15deg);
  width: 100%;
  height: 50vh;
  background-color: #f7c9a5;
}
.box {
  transform: skewY(15deg);
}
h1 {
  margin: 0;
  color: #3d3935;
  font-size: 3rem;
  letter-spacing: 1px;
  text-align: center;
}
@media screen and (max-width: 480px) {
  h1 {
    font-size: 2.25rem;
  }
}