Skip to content

Instantly share code, notes, and snippets.

View Mamboleoo's full-sized avatar

Louis Hoebregts Mamboleoo

View GitHub Profile
@Mamboleoo
Mamboleoo / script.js
Last active November 26, 2019 18:51
Canvas Setup [2D-3D]
// Get the canvas element from the DOM
const canvas = document.getElementById('scene');
// Get the canvas dimensions
let width = canvas.offsetWidth; // Width of the scene
let height = canvas.offsetHeight; // Height of the scene
// Store the 2D context
const ctx = canvas.getContext('2d');
@Mamboleoo
Mamboleoo / style.css
Created January 24, 2019 11:06
CSS Setup [2D-3D]
body {
margin: 0;
overflow: hidden;
}
canvas {
width:100vw;
height:100vh;
}
@Mamboleoo
Mamboleoo / index.html
Created January 24, 2019 11:00
HTML Setup [2D-3D]
<canvas id="scene"></canvas>
.block {
margin-bottom: 10rem;
}
@media (min-width: 700px) {
.block {
margin-bottom: 12.5rem;
}
}
@media (min-width: 1400px) {
.block {
.block {
margin-bottom: 12.5rem; // Fallback for older browsers
margin-bottom: var(--spacing-l); // Responsive spacings
}
.block {
@include spacing(l, margin-bottom);
}
@mixin spacing($type: 'xl', $property: 'margin-top') {
#{$property}: map-get($margins, $type);
#{$property}: var(--margin-#{$type});
}
$spacings: (s: 2rem, m: 6rem, l: 12.5rem, xl: 20rem);
.block {
margin-top: var(--spacing-l);
}
:root {
--spacing-s: 1.5rem;
--spacing-m: 5rem;
--spacing-l: 10rem;
--spacing-xl: 10rem;
@media (min-width: 700px) {
--spacing-s: 2rem;
--spacing-m: 6rem;
--spacing-l: 12.5rem;
--spacing-xl: 20rem;