Skip to content

Instantly share code, notes, and snippets.

@gregwhitworth
gregwhitworth / what-color-square.md
Last active May 31, 2016 04:18
What color box should be visible to the user (just by viewing the code): blue or yellow?

I am wanting to get developer feedback on what you are expecting based on the code below. Please don't run the code in a browser to determine your answer. Purely based on your knowledge of CSS which color box should the user see? Blue or yellow? Leave your answer in the comments. Thank you!!

  <style type='text/css'>
    div, nav {
		width: 200px;
		height: 200px;
	}

	nav, div.c1 {

position: fixed;

@gregwhitworth
gregwhitworth / ri-feature-detection.js
Last active September 4, 2016 08:09
Responsive images feature detection
(function (window) {
document.addEventListener("DOMContentLoaded", function (e) {
var supports = {
srcset: false,
currentSrc: false,
sizes: false,
picture: false
};
var img = new Image();
@gregwhitworth
gregwhitworth / custom-props-basic.css
Created November 16, 2016 01:25
A basic overview of custom properties
:root {
--primary: #0B61A4;
--secondary: #25567B;
}
header {
background: var(--primary);
border-bottom: 2px solid var(--secondary);
}
@gregwhitworth
gregwhitworth / custom-props-fallback.css
Created November 16, 2016 01:55
Custom properties with a fallback value
body {
background: var(--primary, blue);
}
@gregwhitworth
gregwhitworth / custom-props-building.css
Created March 17, 2017 16:51
custom-props-building.css
--building-r-mod: 0;
--building-g-mod: 0;
--building-b-mod: 0;
@gregwhitworth
gregwhitworth / custom-props-building-calc.css
Created March 17, 2017 16:52
custom-props-building-calc.css
.distant-building__window
{
fill: rgb(
calc(111 + (111 * var(--building-r-mod))),
calc(79 + (79 * var(--building-g-mod))),
calc(85 + (85 * var(--building-b-mod)))
);
}
.tail
{
transform: translateY(10px) rotate(var(--tail-rotate));
transform-origin: 60% 84%;
animation: wagTail 250ms infinite;
}
@keyframes wagTail
{
from
var night = function() {
vars = [
{name: "--sky-start", value: "rgb(100, 75, 128)"},
{name: "--sky-end", value: "rgb(45, 45, 81)"},
{name: "--light-r-mod", value: "-17.5"},
{name: "--light-g-mod", value: "25"},
{name: "--light-b-mod", value: "110"},
{name: "--show-stars", value: "block"},
{name: "--building-r-mod", value: "-.25"},
{name: "--building-g-mod", value: 0},
@gregwhitworth
gregwhitworth / custom-props-valid-prop.css
Created February 28, 2017 01:46
custom-props-valid-prop.css
--bg: rgb(calc(var(--r) + var(--modifier)), calc(var(--g) + var(--modifier)), calc(var(--b) + (var(--modifier) + 50)));
@gregwhitworth
gregwhitworth / custom-props-get-prop-value.js
Created February 28, 2017 01:39
custom-props-get-prop.js
var myComponent = document.getElementsByClassName('my-component')[0];
var cs = getComputedStyle(myComponent);
cs.getPropertyValue('--primary');