JSFiddle - React, Tailwind, and code Playground
HTML
<div id="foam"></div>
<div id="liquid"></div>
CSS
body {
padding: 0;
margin: 0 10px;
background: black;
}
#foam {
margin-top: 20px;
background: white;
width: 460px;
height: 100px;
z-index:1;
}
#liquid {
background: #342200;
width: 460px; height: 500px;
position: relative;
clip:auto;
overflow:hidden;
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
z-index:2;
background-image:
-webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(0,50,150)),
color-stop(0.50, rgb(0,150,255))
);
}
#liquid:before {
content: '';
position: absolute;
top: 0; left: 0;
width: 0;
height: 0;
border-style: solid;
border-width: 500px 80px 0 0;
border-color: #000000 transparent transparent transparent;
z-index: 10;
}
#liquid:after {
content: '';
position: absolute;
top: 0; right: 0;
width: 0;
height: 0;
border-style: solid;
border-width: 0 80px 500px 0;
border-color: transparent #000000 transparent transparent;
z-index: 10;
}
.wave{
bottom:0;
background:#fff;
display:inline-block;
height:10%;
width:10px;
position:absolute;
-webkit-animation-name: dostuff;
-webkit-animation-duration: 3s;
-webkit-animation-iteration-count: infinite;
-webkit-transition-timing-function: ease-in-out;
z-index:3;
}
@-webkit-keyframes dostuff{
0%, 100% {
height:10%;
}
50% {
height:20%;
}
}
JavaScript
// make some waves.
var liquid = document.getElementById("liquid"),
waveWidth = 10,
waveCount = Math.floor(liquid.offsetWidth/waveWidth),
docFrag = document.createDocumentFragment();
for(var i = 0; i < waveCount; i++){
var wave = document.createElement("div");
wave.className += " wave";
docFrag.appendChild(wave);
wave.style.left = i * waveWidth + "px";
wave.style.webkitAnimationDelay = (i/100) + "s";
}
liquid.appendChild(docFrag);