4 Color Background with CSS linear-gradient

01/27/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>4 Color Background with CSS linear-gradient</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">
      <h1>4 Color Background</h1>
    </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-image: linear-gradient(to right, #4285f4 0%, #4285f4 50%, #db4437 50%, #db4437 100%),
              linear-gradient(to right, #f4b400 0%, #f4b400 50%, #0f9d58 50%, #0f9d58 100%);
  background-position: center top, center bottom;
  background-size: 100% 50%;
  background-repeat: no-repeat;
}
h1 {
  margin: 0;
  padding: 20px;
  background-color: #fff;
  color: #3d3935;
  font-size: 2.5rem;
  letter-spacing: 1px;
  text-align: center;
}
@media screen and (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }
}