<div class="funky funky--top">
<span />
</div>
<div class="funky funky--right">
<span />
</div>
<div class="funky funky--bottom">
<span />
</div>
<div class="funky funky--left">
<span />
</div>
:root {
--border-width: 3rem;
--squish-speed: 0.8s;
}
body {
min-height: 100vh;
margin: 0;
}
.funky {
display: flex;
position: absolute;
background: orange;
}
.funky--top {
top: 0;
left: 0;
z-index: 1;
width: 100%;
}
.funky--right {
right: 0;
top: 0;
height: 100vh;
width: var(--border-width);
flex-direction: column;
}
.funky--bottom {
bottom: 0;
left: 0;
z-index: 1;
width: 100%;
}
.funky--left {
top: 0;
left: 0;
height: 100%;
width: var(--border-width);
flex-direction: column;
}
.funky > * {
display: block;
flex: 1;
height: var(--border-width);
background: orange;
transition: all var(--squish-speed) ease-out;
animation: grow var(--squish-speed) ease-out;
}
@keyframes grow {
0% {
flex-grow: 0.00001;
}
100% {
flex-grow: 1;
}
}
View Compiled
document.body.style.backgroundColor = randomRgbaString(1);
var funkies = document.querySelectorAll('.funky');
for (const funky of funkies) {
funky.addEventListener('mouseenter', function(event) {
makeBar();
})
}
function makeBar(target) {
for (const funky of funkies) {
var el = document.createElement('span');
funky.appendChild(el);
colorizeBars();
}
}
function colorizeBars() {
var bars = document.querySelectorAll('.funky > span');
for (i = 0; i < bars.length; i++) {
bars[i].style.backgroundColor = randomRgbaString(1);
}
}
function randomRgbaString (alpha) {
let r = Math.floor(Math.random() * 255)
let g = Math.floor(Math.random() * 255)
let b = Math.floor(Math.random() * 255)
let a = alpha
return `rgba(${r},${g},${b},${a})`
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.