logo

Background animation

Diamonds Animation

Lien d’origine: https://codepen.io/DonKarlssonSan/pen/jObRYYW

HTML:

<section class="diamondsAnimations">
<canvas class="diamandscanvas block"></canvas>
<script src="http://localhost/wordpress/wp-content/themes/theme-bulma-v4.1.2/js/diamonds_animation.js"></script>
</section>

JS:

let canvas;
let ctx;
let w, h;
function setup() {
ticker = 0;
canvas = document.querySelector(".diamandscanvas");
ctx = canvas.getContext("2d");
resize();
window.addEventListener("resize", resize);
}
function resize() {
w = canvas.width = window.innerWidth;
h = canvas.height = window.innerHeight;
}
function draw(now) {
requestAnimationFrame(draw);
ctx.fillStyle = "white";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "black";
let size = 50;
let xSpace = Math.sqrt(2 * size ** 2);
let ySpace = xSpace / 2;
let nrOfRows = Math.round(h / ySpace + ySpace);
for (let col = 0; col < w / xSpace + xSpace; col++) {
for (let row = 0; row < nrOfRows; row++) {
let x = col * xSpace;
let y = row * ySpace;
let xOffset = row % 2 * xSpace / 2;
let scaledSize = ((Math.sin(now / 1000 + row / 5) + 1) * 0.38 + 0.1) * size;
ctx.lineWidth = scaledSize * 0.1 + 1;
drawSquare(x + xOffset, y, scaledSize);
}
}
}
function drawSquare(x, y, size) {
ctx.save();
ctx.translate(x, y);
ctx.rotate(Math.PI / 4);
ctx.strokeRect(-size / 2, -size / 2, size, size);
ctx.restore();
}
setup();
draw(1);

404 galaxy not found

Lien d’origine: https://codepen.io/remid/details/YOVawm

HTML:

<section class="GalaxyNotFound">
<div class='container'>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>4</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<span class='particle'>0</span>
<article class='content'>
<p>Damnit stranger,</p>
<p>You got lost in the <strong>404</strong> galaxy.</p>
<p>
<button>Go back to earth.</button>
</p>
</article>
</div>
</section>

CSS:

.GalaxyNotFound {
margin: 0;
font-size: 20px;
}
.GalaxyNotFound {
box-sizing: border-box;
}
.GalaxyNotFound .container {
position: relative;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background: white;
color: black;
font-family: arial, sans-serif;
overflow: hidden;
}
.GalaxyNotFound .content {
position: relative;
width: 600px;
max-width: 100%;
margin: 20px;
background: white;
padding: 60px 40px;
text-align: center;
box-shadow: -10px 10px 67px -12px rgba(0, 0, 0, 0.2);
opacity: 0;
animation: apparition 0.8s 1.2s cubic-bezier(0.39, 0.575, 0.28, 0.995) forwards;
}
.GalaxyNotFound .content p {
font-size: 1.3rem;
margin-top: 0;
margin-bottom: 0.6rem;
letter-spacing: 0.1rem;
color: #595959;
}
.GalaxyNotFound .content p:last-child {
margin-bottom: 0;
}
.GalaxyNotFound .content button {
display: inline-block;
margin-top: 2rem;
padding: 0.5rem 1rem;
border: 3px solid #595959;
background: transparent;
font-size: 1rem;
color: #595959;
text-decoration: none;
cursor: pointer;
font-weight: bold;
}

.GalaxyNotFound .particle {
position: absolute;
display: block;
pointer-events: none;
}
.GalaxyNotFound .particle:nth-child(1) {
top: 35.3808353808%;
left: 53.2544378698%;
font-size: 14px;
filter: blur(0.02px);
animation: 36s float infinite;
}
.GalaxyNotFound .particle:nth-child(2) {
top: 41.0256410256%;
left: 5.8881256133%;
font-size: 19px;
filter: blur(0.04px);
animation: 25s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(3) {
top: 75.1807228916%;
left: 88.3495145631%;
font-size: 30px;
filter: blur(0.06px);
animation: 23s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(4) {
top: 48.4261501211%;
left: 69.2007797271%;
font-size: 26px;
filter: blur(0.08px);
animation: 22s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(5) {
top: 93.3660933661%;
left: 28.5996055227%;
font-size: 14px;
filter: blur(0.1px);
animation: 31s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(6) {
top: 42.6150121065%;
left: 79.9220272904%;
font-size: 26px;
filter: blur(0.12px);
animation: 33s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(7) {
top: 72.9040097205%;
left: 94.8191593353%;
font-size: 23px;
filter: blur(0.14px);
animation: 38s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(8) {
top: 60.1726263872%;
left: 41.5430267062%;
font-size: 11px;
filter: blur(0.16px);
animation: 35s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(9) {
top: 12.5301204819%;
left: 44.6601941748%;
font-size: 30px;
filter: blur(0.18px);
animation: 40s float infinite;
}
.GalaxyNotFound .particle:nth-child(10) {
top: 4.9200492005%;
left: 95.7551826259%;
font-size: 13px;
filter: blur(0.2px);
animation: 33s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(11) {
top: 21.2560386473%;
left: 90.46692607%;
font-size: 28px;
filter: blur(0.22px);
animation: 36s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(12) {
top: 89.9637243047%;
left: 14.605647517%;
font-size: 27px;
filter: blur(0.24px);
animation: 29s float infinite;
}
.GalaxyNotFound .particle:nth-child(13) {
top: 83.192261185%;
left: 43.8169425511%;
font-size: 27px;
filter: blur(0.26px);
animation: 31s float infinite;
}
.GalaxyNotFound .particle:nth-child(14) {
top: 56.3791008505%;
left: 43.9882697947%;
font-size: 23px;
filter: blur(0.28px);
animation: 40s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(15) {
top: 22.4938875306%;
left: 42.2396856582%;
font-size: 18px;
filter: blur(0.3px);
animation: 38s float infinite;
}
.GalaxyNotFound .particle:nth-child(16) {
top: 4.9261083744%;
left: 25.6916996047%;
font-size: 12px;
filter: blur(0.32px);
animation: 22s float infinite;
}
.GalaxyNotFound .particle:nth-child(17) {
top: 61.0909090909%;
left: 46.8292682927%;
font-size: 25px;
filter: blur(0.34px);
animation: 38s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(18) {
top: 25.4901960784%;
left: 28.5433070866%;
font-size: 16px;
filter: blur(0.36px);
animation: 38s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(19) {
top: 43.4782608696%;
left: 72.9571984436%;
font-size: 28px;
filter: blur(0.38px);
animation: 29s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(20) {
top: 24.3902439024%;
left: 2.9411764706%;
font-size: 20px;
filter: blur(0.4px);
animation: 35s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(21) {
top: 52.3636363636%;
left: 68.2926829268%;
font-size: 25px;
filter: blur(0.42px);
animation: 28s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(22) {
top: 38.8821385176%;
left: 51.8084066471%;
font-size: 23px;
filter: blur(0.44px);
animation: 39s float infinite;
}
.GalaxyNotFound .particle:nth-child(23) {
top: 43.3734939759%;
left: 14.5631067961%;
font-size: 30px;
filter: blur(0.46px);
animation: 21s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(24) {
top: 31.8455971049%;
left: 2.915451895%;
font-size: 29px;
filter: blur(0.48px);
animation: 23s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(25) {
top: 14.4927536232%;
left: 87.5486381323%;
font-size: 28px;
filter: blur(0.5px);
animation: 29s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(26) {
top: 72.7272727273%;
left: 3.9447731755%;
font-size: 14px;
filter: blur(0.52px);
animation: 26s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(27) {
top: 46.265060241%;
left: 36.8932038835%;
font-size: 30px;
filter: blur(0.54px);
animation: 25s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(28) {
top: 28.1212121212%;
left: 13.6585365854%;
font-size: 25px;
filter: blur(0.56px);
animation: 39s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(29) {
top: 22.6044226044%;
left: 52.2682445759%;
font-size: 14px;
filter: blur(0.58px);
animation: 29s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(30) {
top: 49.9388004896%;
left: 18.6823992134%;
font-size: 17px;
filter: blur(0.6px);
animation: 37s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(31) {
top: 23.3009708738%;
left: 87.890625%;
font-size: 24px;
filter: blur(0.62px);
animation: 36s float infinite;
}
.GalaxyNotFound .particle:nth-child(32) {
top: 10.71863581%;
left: 37.2184133203%;
font-size: 21px;
filter: blur(0.64px);
animation: 28s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(33) {
top: 1.9347037485%;
left: 2.9211295034%;
font-size: 27px;
filter: blur(0.66px);
animation: 24s float infinite;
}
.GalaxyNotFound .particle:nth-child(34) {
top: 60.7228915663%;
left: 23.3009708738%;
font-size: 30px;
filter: blur(0.68px);
animation: 33s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(35) {
top: 27.0205066345%;
left: 88.4353741497%;
font-size: 29px;
filter: blur(0.7px);
animation: 30s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(36) {
top: 97.6572133169%;
left: 30.6627101879%;
font-size: 11px;
filter: blur(0.72px);
animation: 25s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(37) {
top: 42.0024420024%;
left: 77.5269872424%;
font-size: 19px;
filter: blur(0.74px);
animation: 32s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(38) {
top: 85.3333333333%;
left: 52.6829268293%;
font-size: 25px;
filter: blur(0.76px);
animation: 33s float infinite;
}
.GalaxyNotFound .particle:nth-child(39) {
top: 1.9512195122%;
left: 0.9803921569%;
font-size: 20px;
filter: blur(0.78px);
animation: 22s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(40) {
top: 33.4152334152%;
left: 0.9861932939%;
font-size: 14px;
filter: blur(0.8px);
animation: 33s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(41) {
top: 29.0556900726%;
left: 85.7699805068%;
font-size: 26px;
filter: blur(0.82px);
animation: 30s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(42) {
top: 50.5467800729%;
left: 31.2805474096%;
font-size: 23px;
filter: blur(0.84px);
animation: 36s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(43) {
top: 9.6501809409%;
left: 38.8726919339%;
font-size: 29px;
filter: blur(0.86px);
animation: 25s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(44) {
top: 74.0560292326%;
left: 32.3212536729%;
font-size: 21px;
filter: blur(0.88px);
animation: 23s float infinite;
}
.GalaxyNotFound .particle:nth-child(45) {
top: 40.097799511%;
left: 19.6463654224%;
font-size: 18px;
filter: blur(0.9px);
animation: 38s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(46) {
top: 5.9113300493%;
left: 85.9683794466%;
font-size: 12px;
filter: blur(0.92px);
animation: 26s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(47) {
top: 95.2147239264%;
left: 80.7881773399%;
font-size: 15px;
filter: blur(0.94px);
animation: 34s float infinite;
}
.GalaxyNotFound .particle:nth-child(48) {
top: 3.9457459926%;
left: 14.8367952522%;
font-size: 11px;
filter: blur(0.96px);
animation: 40s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(49) {
top: 57.2133168927%;
left: 25.7171117705%;
font-size: 11px;
filter: blur(0.98px);
animation: 34s float infinite;
}
.GalaxyNotFound .particle:nth-child(50) {
top: 62.0689655172%;
left: 80.0395256917%;
font-size: 12px;
filter: blur(1px);
animation: 37s float infinite;
}
.GalaxyNotFound .particle:nth-child(51) {
top: 57.2815533981%;
left: 7.8125%;
font-size: 24px;
filter: blur(1.02px);
animation: 26s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(52) {
top: 23.3576642336%;
left: 21.5264187867%;
font-size: 22px;
filter: blur(1.04px);
animation: 34s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(53) {
top: 69.7336561743%;
left: 58.4795321637%;
font-size: 26px;
filter: blur(1.06px);
animation: 29s float infinite;
}
.GalaxyNotFound .particle:nth-child(54) {
top: 60.7961399276%;
left: 79.6890184645%;
font-size: 29px;
filter: blur(1.08px);
animation: 37s float infinite;
}
.GalaxyNotFound .particle:nth-child(55) {
top: 67.8966789668%;
left: 93.7808489635%;
font-size: 13px;
filter: blur(1.1px);
animation: 32s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(56) {
top: 79.2270531401%;
left: 27.2373540856%;
font-size: 28px;
filter: blur(1.12px);
animation: 28s float infinite;
}
.GalaxyNotFound .particle:nth-child(57) {
top: 81.7518248175%;
left: 87.084148728%;
font-size: 22px;
filter: blur(1.14px);
animation: 35s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(58) {
top: 75.1807228916%;
left: 33.9805825243%;
font-size: 30px;
filter: blur(1.16px);
animation: 25s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(59) {
top: 78.7207872079%;
left: 8.8845014808%;
font-size: 13px;
filter: blur(1.18px);
animation: 30s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(60) {
top: 52.6829268293%;
left: 91.1764705882%;
font-size: 20px;
filter: blur(1.2px);
animation: 31s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(61) {
top: 83.3333333333%;
left: 72.8346456693%;
font-size: 16px;
filter: blur(1.22px);
animation: 40s float infinite;
}
.GalaxyNotFound .particle:nth-child(62) {
top: 46.8864468864%;
left: 26.4965652601%;
font-size: 19px;
filter: blur(1.24px);
animation: 22s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(63) {
top: 76.6990291262%;
left: 17.578125%;
font-size: 24px;
filter: blur(1.26px);
animation: 33s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(64) {
top: 14.7058823529%;
left: 47.2440944882%;
font-size: 16px;
filter: blur(1.28px);
animation: 31s float infinite;
}
.GalaxyNotFound .particle:nth-child(65) {
top: 78.239608802%;
left: 19.6463654224%;
font-size: 18px;
filter: blur(1.3px);
animation: 29s float infinite;
}
.GalaxyNotFound .particle:nth-child(66) {
top: 92.6417370326%;
left: 5.8309037901%;
font-size: 29px;
filter: blur(1.32px);
animation: 21s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(67) {
top: 45.7978075518%;
left: 16.6503428012%;
font-size: 21px;
filter: blur(1.34px);
animation: 24s float infinite;
}
.GalaxyNotFound .particle:nth-child(68) {
top: 27.4509803922%;
left: 44.2913385827%;
font-size: 16px;
filter: blur(1.36px);
animation: 39s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(69) {
top: 12.5755743652%;
left: 16.553067186%;
font-size: 27px;
filter: blur(1.38px);
animation: 26s floatReverse infinite;
}
.GalaxyNotFound .particle:nth-child(70) {
top: 68.3760683761%;
left: 57.8999018646%;
font-size: 19px;
filter: blur(1.4px);
animation: 31s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(71) {
top: 86.1985472155%;
left: 38.9863547758%;
font-size: 26px;
filter: blur(1.42px);
animation: 40s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(72) {
top: 31.5659679408%;
left: 91.9881305638%;
font-size: 11px;
filter: blur(1.44px);
animation: 37s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(73) {
top: 34.188034188%;
left: 80.4710500491%;
font-size: 19px;
filter: blur(1.46px);
animation: 30s float infinite;
}
.GalaxyNotFound .particle:nth-child(74) {
top: 93.023255814%;
left: 43.2645034415%;
font-size: 17px;
filter: blur(1.48px);
animation: 33s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(75) {
top: 19.680196802%;
left: 77.9861796644%;
font-size: 13px;
filter: blur(1.5px);
animation: 25s float2 infinite;
}
.GalaxyNotFound .particle:nth-child(76) {
top: 46.3054187192%;
left: 26.6798418972%;
font-size: 12px;
filter: blur(1.52px);
animation: 27s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(77) {
top: 70.6748466258%;
left: 45.3201970443%;
font-size: 15px;
filter: blur(1.54px);
animation: 31s float infinite;
}
.GalaxyNotFound .particle:nth-child(78) {
top: 46.7153284672%;
left: 90.0195694716%;
font-size: 22px;
filter: blur(1.56px);
animation: 31s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(79) {
top: 30.4294478528%;
left: 95.5665024631%;
font-size: 15px;
filter: blur(1.58px);
animation: 26s floatReverse2 infinite;
}
.GalaxyNotFound .particle:nth-child(80) {
top: 67.0716889429%;
left: 30.303030303%;
font-size: 23px;
filter: blur(1.6px);
animation: 32s floatReverse infinite;
}
@keyframes apparition {
from {
opacity: 0;
transform: translateY(100px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes float {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(180px);
}
}
@keyframes floatReverse {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-180px);
}
}
@keyframes float2 {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(28px);
}
}
@keyframes floatReverse2 {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-28px);
}
}