<main>
<div class="tv-body">
<div class="screen-container">
<canvas id="static" width="380" height="280"></canvas>
<img id="displayed" src="" alt="Nothing" width="380" height="280">
<div class="screen">
<div class="screen-frame"></div>
<div class="screen-inset"></div>
</div>
</div>
<div class="logo-badge">
<div class="logo-text">Bush</div>
</div>
<div class="controls">
<div class="panel">
<div class="screw"></div>
<div class="dial">
<button id="channel" class="dial-label pristine">Channel</button>
</div>
</div>
<div class="vents">
<div class="vent"></div>
<div class="vent"></div>
<div class="vent"></div>
<div class="vent"></div>
<div class="vent"></div>
<div class="vent"></div>
</div>
<div class="panel">
<div class="screw"></div>
<div class="dial">
<button class="dial-label" disabled>Volume</button>
</div>
</div>
</div>
</div>
<div class="legs">
<div class="leg"></div>
<div class="leg"></div>
</div>
</main>
* {
border: 0;
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background: #cbb;
height: 100vh;
}
main {
font-size: 10px;
margin: auto;
width: 51em;
height: 52.5em;
}
img, canvas {
display: block;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
img {
width: 32em;
height: 22em;
}
body, .tv-body, .controls, .legs {
display: flex;
}
.tv-body, .controls {
justify-content: center;
}
.tv-body {
background-color: #8c5b3d;
background-image:
radial-gradient(10em 0.4em at 8em 0.8em,#fff,#fff0),
radial-gradient(10em 0.4em at 20em 0.8em,#fff,#fff0),
radial-gradient(10em 0.4em at 36em 0.8em,#fff,#fff0),
radial-gradient(14em 0.8em at 6em 2em,#fff 50%,#fff0),
radial-gradient(55em 0.4em at 50% 2em,#fff3,#fff0),
linear-gradient(#0000,#0004),
radial-gradient(12em 0.4em at 32em 2em,#fff,#fff0),
url("https://assets.codepen.io/416221/vintage-tv-texture.jpg");
border-radius: 0.75em 0.75em 0.75em 0.75em / 3em 3em 0.75em 0.75em;
box-shadow: 0 -1em 0.75em #ba816c7f inset;
flex-direction: column;
align-items: center;
height: 51em;
}
.screen-container, .controls {
width: 38em;
}
.screen-container {
background-color: #bcb;
margin: 3em 0 0 0;
overflow: hidden;
position: relative;
height: 28em;
}
.screen, .screen-inset, .screen-frame, canvas, img {
position: absolute;
}
.screen, .screen-inset {
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.screen {
background-image:
radial-gradient(1em 1em at 22% 19%,#fff 25%,#fff0),
radial-gradient(4em 1.5em at 35% 17%,#fff 35%,#fff0),
radial-gradient(1em 1em at 82% 24%,#fff 25%,#fff0),
radial-gradient(100% 175% at 50% 50%,#0000 32%,#000 60%),
radial-gradient(175% 100% at 50% 53%,#0000 32%,#000 60%);
}
.screen-inset {
box-shadow: 0 -0.1em 0.1em 0.6em #3a1415 inset;
}
.screen-frame {
border-top: 8em solid #7b807d;
border-right: 8em solid #9da28f;
border-bottom: 8em solid #b0b5a0;
border-left: 8em solid #8c917e;
border-radius: 16em;
box-shadow: 0 0.1em 0.2em 0.2em #0007 inset;
top: 50%;
left: 50%;
width: calc(100% + 9.5em);
height: calc(100% + 10em);
transform: translate(-50%,-50%);
}
.logo-badge, .logo-badge:before, .logo-badge:after {
background: #401f25;
}
.logo-badge, .dial-label {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.logo-badge {
border-radius: 0.25em;
box-shadow:
0 0.2em 0.2em #fff4 inset,
0 -0.2em 0.2em #0004 inset;
color: #aa5;
cursor: default;
font: 1.5em Playball, cursive;
line-height: 1.5;
margin: 0.4em 0;
position: relative;
text-align: center;
width: 2.4em;
height: 1.5em;
}
.logo-badge:before, .logo-badge:after {
content: "";
display: block;
position: absolute;
top: 0.2em;
width: 1.2em;
height: 1em;
}
.logo-badge:before {
border-radius: 50% 0 0 50%;
box-shadow:
0.1em 0.1em 0.2em #fff4 inset,
0.1em -0.1em 0.2em #0004 inset;
right: 95%;
}
.logo-badge:after {
border-radius: 0 50% 50% 0;
box-shadow:
-0.1em 0.1em 0.2em #fff4 inset,
-0.1em -0.1em 0.2em #0004 inset;
left: 95%;
}
.logo-text {
transform: scaleX(0.75);
}
.controls {
background-color: currentColor;
border-radius: 1.5em;
box-shadow:
0 0.3em 0.5em 0.5em #0007,
0 0 0.5em 0.4em inset,
0 -0.1em 0.3em 0.3em #fffc inset,
0 0.1em 0.2em 1em inset,
0 1.6em 0.4em 0 #fff4 inset,
0 -1.3em 0.4em 0 #fff6 inset,
0.2em 0.9em 0.25em 1.5em #0007 inset,
0 -2.2em 0.1em #ffffff17 inset,
0 -2.5em 0.2em #0002 inset;
color: #401f25;
padding-top: 2.4em;
height: 12em;
}
.panel, .vents {
height: 8.5em;
}
.panel {
width: 5.5em;
}
.screw, .dial {
border-radius: 50%;
}
.screw {
background-color: #fff1;
background-image: linear-gradient(#0000 38%,#0005 38%,#0005 55%,#fff3 55%,#fff3 67%,#fff0 67%);
box-shadow: 0 0 0 0.3em #0005;
margin: 0 auto 1em auto;
width: 2em;
height: 2em;
transform: rotate(45deg);
}
.dial {
box-shadow:
0 0 0.2em 0.5em #0003,
-0.2em 0.3em 0.2em 0.5em #ffffff17 inset,
0 0 0 0.6em inset;
margin: auto;
position: relative;
width: 5em;
height: 5em;
}
.dial-label {
background-color: transparent;
border-radius: 50%;
color: #994;
cursor: pointer;
font: bold 0.7em sans-serif;
line-height: 5;
position: absolute;
bottom: 0.2em;
left: 0.4em;
text-align: center;
text-shadow: 0 0.2em 0 #000;
text-transform: uppercase;
transition: transform 0.2s ease-in-out;
width: 6em;
height: 6em;
-webkit-appearance: none;
appearance: none;
}
.dial-label:disabled {
cursor: not-allowed;
}
.dial-label:focus {
outline: transparent;
}
.panel:last-child .screw {
transform: rotate(25deg);
}
.panel:last-child .dial {
box-shadow:
0 0 0.2em 0.5em #0003,
0.2em 0.3em 0.2em 0.5em #ffffff17 inset,
0 0 0 0.6em inset;
}
.panel:last-child .dial-label {
left: 0.8em;
}
.vents {
width: 24em;
}
.vent {
background-color: #fff7;
border-radius: 0.75em;
box-shadow:
0 -0.7em 0.3em inset,
0 -0.2em 0.2em #fff3,
0 0.5em 0.3em #000c;
margin-bottom: 0.4em;
width: 100%;
height: 1em;
}
.legs {
background-color: #462b34;
box-shadow: 0 0.5em 0.4em #462b34;
justify-content: space-between;
margin: auto;
width: 49em;
height: 1.5em;
}
.leg {
background-color: #765c62;
box-shadow: 0 0.4em 0.3em #0007 inset;
width: 7em;
height: 100%;
}
.pristine {
animation: glow 1.5s linear infinite;
box-shadow: 0 0 1em #ff0;
}
.hide {
display: none;
}
@keyframes glow {
from, to {box-shadow: 0 0 1em 0 #ff0 }
50% { box-shadow: 0 0 3em 0 #ff0 }
}
document.addEventListener("DOMContentLoaded",tv);
function tv() {
var cnv = document.getElementById("static"),
c = cnv.getContext("2d"),
cw = cnv.offsetWidth,
ch = cnv.offsetHeight,
staticScrn = c.createImageData(cw,ch),
staticFPS = 30,
isStatic = false,
staticTO,
gifData = [
{
file: "https://assets.codepen.io/416221/willie.gif",
desc: "Steamboat Willie (Mickey Mouse) steering a ship"
},
{
file: "https://assets.codepen.io/416221/skeletons.gif",
desc: "Spooky scary skeletons sending shivers down your spine"
},
{
file: "https://assets.codepen.io/416221/kingkong.gif",
desc: "King Kong waving on Empire State Building",
},
{
file: "https://assets.codepen.io/416221/tracks.gif",
desc: "Looking at train tracks from behind a train",
},
{
file: "https://assets.codepen.io/416221/nuke.gif",
desc: "Nuclear explosion at sea",
}
],
gifs = [],
channel = 0;
for (g in gifData) {
gifs.push(new Image());
gifs[g].src = gifData[g].file;
gifs[g].alt = gifData[g].desc;
}
/* Static */
var runStatic = function() {
isStatic = true;
c.clearRect(0,0,cw,ch);
for (var i = 0; i < staticScrn.data.length; i += 4) {
let shade = 127 + Math.round(Math.random() * 128);
staticScrn.data[0 + i] = shade;
staticScrn.data[1 + i] = shade;
staticScrn.data[2 + i] = shade;
staticScrn.data[3 + i] = 255;
}
c.putImageData(staticScrn,0,0);
staticTO = setTimeout(runStatic,1e3/staticFPS);
};
runStatic();
/* Channels */
var changeChannel = function() {
var displayed = document.getElementById("displayed");
++channel;
if (channel > gifData.length)
channel = 1;
this.classList.remove("pristine");
this.style.transform = `rotate(${channel * 360/(gifData.length + 1)}deg)`;
cnv.classList.remove("hide");
displayed.classList.add("hide");
if (!isStatic)
runStatic();
setTimeout(function(){
cnv.classList.add("hide");
displayed.classList.remove("hide");
displayed.src = gifs[channel - 1].src;
displayed.alt = gifs[channel - 1].alt;
isStatic = false;
clearTimeout(staticTO);
},300);
};
document.getElementById("channel").addEventListener("click",changeChannel);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.