Pure CSS Zig Zag Border

01/01/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>Pure CSS Zig Zag Border</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">
      <div class="zigzag">
        <h1>Pure CSS<br>Zig Zag Border</h1>
      </div>
    </div>
  </body>
</html>

CSS

@charset "utf-8";
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
}
body {
  background-color: #164473;
  font-family: futura-pt, sans-serif;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}
#container {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  width: 100%;
  height: 100vh;
}
.zigzag {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
  height: 80vh;
  background: #1de0ef;
}
.zigzag::before {
  position: absolute;
  top: -15px;
  width: 100%;
  height: 15px;
  background-image: linear-gradient(45deg, #1de0ef 50%, transparent 50%),
              linear-gradient(-45deg, #1de0ef 50%, transparent 50%);
  background-size: 30px 30px;
  content: '';
}
h1 {
  margin: 0 0 10vh;
  color: #164473;
  font-size: 4.25rem;
  letter-spacing: 1px;
  text-align: center;
}
@media screen and (max-width: 480px) {
  h1 {
    font-size: 2.25rem;
  }
}