JSFiddle - React, Tailwind, and code Playground

by Lalji Tadhani

HTML

<div class="parent">
<div class="child"></div>
<canvas id="canvas" width=300 height=75/>
</div>

CSS

.parent {
  width: 300px;
  height: 300px;
  align-items: center;
  justify-content: center;
  display: flex;
  flex-direction: column;
  background-color: #6EE2F5;
}
.child {
  width: 300px;
  height: 75px;
  border: 1px solid red;
  background-image: linear-gradient(to right top, red, blue);
  
  /* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#ff0000+0,1f00e0+100 */
background: #ff0000; /* Old browsers */
background: -moz-linear-gradient(left, #ff0000 0%, #1f00e0 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(left, red 0%,blue 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to right, #ff0000 0%,#1f00e0 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff0000', endColorstr='#1f00e0',GradientType=1 ); /* IE6-9 
}
#canvas {
  width: 300px;
  height: 75px;
  border: 1px solid green;
}

JavaScript

var c = document.getElementById("canvas");
var ctx = c.getContext("2d");

var grd = ctx.createLinearGradient(0, 75, 300, 0);
grd.addColorStop(0, "red");
grd.addColorStop(1, "blue");

ctx.fillStyle = grd;
ctx.fillRect(0, 0, 300, 75);