Skip to content

Instantly share code, notes, and snippets.

@Daniel-Hug
Daniel-Hug / dabblet.css
Created January 14, 2012 02:22
A "deeper" indented text effect with the :before and :after pseudo-elements.
/**
* A "deeper" indented text effect with the :before and :after pseudo-elements.
*/
html, body {
height: 100%;
}
body {
margin: 0;
@Daniel-Hug
Daniel-Hug / dabblet.css
Created March 28, 2012 06:49
Pure CSS stopwatch
/**
* Pure CSS stopwatch
*/
* { box-sizing: border-box; -moz-box-sizing: border-box }
html { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAOklEQVQIWx3K2QkAMAgFwadEsBjF/ksTD0Kyn8uQme05BzOD3QW5+2YmVBWvP6oKIoLuBkXEF48zMy6Jfxr7Roi85AAAAABJRU5ErkJggg==) }
body {
text-align: center;
@Daniel-Hug
Daniel-Hug / dabblet.css
Created May 4, 2012 01:19
Pure CSS aspect ratio with no spacer images or js! :)
/*
* Pure CSS aspect ratio with no spacer images or js! :)
*/
body {
width: 36%;
margin: 8px auto;
}
div.stretchy-wrapper {
@Daniel-Hug
Daniel-Hug / dabblet.css
Created April 17, 2013 20:33
keyframe animation test
/**
* keyframe animation test
*/
@-webkit-keyframes myanim {
50% { background: blue }
}
@-moz-keyframes myanim {
50% { background: blue }
// Function.bind polyfill:
open.bind||(Function.prototype.bind=function(b){function c(){return d.apply(this instanceof a&&b?this:b,e.concat([].slice.call(arguments)))}function a(){}var e=[].slice.call(arguments,1),d=this;a.prototype=this.prototype;c.prototype=new a;return c});
@Daniel-Hug
Daniel-Hug / function-bind.js
Last active August 31, 2017 11:26 — forked from dsingleton/function-bind.js
Polyfill for Function.prototype.bind
Function.prototype.bind=(function(){}).bind||function(b){if(typeof this!=="function"){throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");}function c(){}var a=[].slice,f=a.call(arguments,1),e=this,d=function(){return e.apply(this instanceof c?this:b||window,f.concat(a.call(arguments)));};c.prototype=this.prototype;d.prototype=new c();return d;};
@Daniel-Hug
Daniel-Hug / selection-styling.css
Created October 4, 2013 05:11
Style Text Selection with CSS3
/* Change selection color------------------------------------------------------------*/
::-moz-selection { background: #000; color: #fff; text-shadow: none }
::selection { background: #000; color: #fff; text-shadow: none }
@Daniel-Hug
Daniel-Hug / HTML5-Shiv.html
Created October 4, 2013 05:12
HTML5 Shiv/Shim
<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
@Daniel-Hug
Daniel-Hug / Decrementing-for-loop.js
Created October 4, 2013 05:15
Decrementing for loop with cached variable
for (var i = document.images.length; i--;) {
document.images[i].src = 'cat.png';
}
@Daniel-Hug
Daniel-Hug / select.js
Created October 4, 2013 05:20
Select text with Javascript
codeElements = document.getElementsByTagName('code');
for (var i = codeElements.length; i--;) {
codeElements[i].onclick = function() {
var range;
if (document.selection) {
range = document.body.createTextRange();
range.moveToElementText(this);
range.select();
}