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);
}
div {
--primary: blue;
margin-top: var(--primary, 12px);
}
@gregwhitworth
gregwhitworth / custom-props-feature-detection.css
Last active March 17, 2017 17:32
custom-props-feature-detection.css
body {
background: red;
}
@supports(--foo: blue) {
body {
background: green;
}
}
@gregwhitworth
gregwhitworth / custom-props-feature-detection-2.css
Created February 27, 2017 23:30
custom-props-feature-detection-2.css
:root {
--foo: true;
}
body {
background: red;
}
@supports(--foo: false) {
body {
@gregwhitworth
gregwhitworth / custom-props-animate.css
Created February 27, 2017 23:57
custom-props-animate.css
div {
--pos: 0;
left: var(--pos);
animation: move 1s;
}
@keyframes move {
to {
--pos: 50px;
}
@gregwhitworth
gregwhitworth / custom-props-scoping.css
Created February 28, 2017 00:25
custom-props-scoping.css
body {
--primary: blue;
background: var(--primary);
}
.my-component {
--primary: yellow;
background: var(--primary);
}
@gregwhitworth
gregwhitworth / custom-props-set-property.js
Created February 28, 2017 01:34
custom-props-set-property.js
var myComponent = document.getElementsByClassName('my-component')[0];
myComponent.style.setProperty('--primary', 'green');