Skip to content

Instantly share code, notes, and snippets.

View jelmerdemaat's full-sized avatar

Jelmer jelmerdemaat

View GitHub Profile
@jelmerdemaat
jelmerdemaat / clearfix.css
Created September 29, 2012 15:44
Clearfix by Nicolas Gallagher (updated)
/**
* Source: http://nicolasgallagher.com/micro-clearfix-hack/
*
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
@jelmerdemaat
jelmerdemaat / gist:3806746
Created September 30, 2012 13:35
HTML: Small HTML5 starter template
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>A title</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<header>
@jelmerdemaat
jelmerdemaat / dabblet.css
Created October 6, 2012 20:30
How to do a continuous animation
/**
* How to do a continuous animation
*/
div{
width: 300px;
height: 300px;
background: yellow;
animation-duration: 4s;
@jelmerdemaat
jelmerdemaat / dabblet.css
Created October 6, 2012 20:33
FLOATS, WHY U NO WORK?
/**
* FLOATS, WHY U NO WORK?
*/
div{
float:left;
width: 33.3333%
}
div:last-child{
float:right;
@jelmerdemaat
jelmerdemaat / dabblet.css
Created October 6, 2012 20:53
FLOATS, WHY U NO WORK?
/**
* FLOATS, WHY U NO WORK?
*/
div{
float:left;
width: 60%;
background: firebrick;
color: white;
outline: 1px solid black;
@jelmerdemaat
jelmerdemaat / rAF.js
Created November 2, 2012 11:43 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function () {
var lastTime = 0,
vendors = ['ms', 'moz', 'webkit', 'o'];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@jelmerdemaat
jelmerdemaat / gist:4024553
Created November 6, 2012 12:55
Change <html> class name (e.g. no-js)
// source: http://stackoverflow.com/questions/8708826/how-to-replace-class-html-name-with-javascript
var els = [].slice.apply(document.getElementsByClassName("no-js"));
for (var i = 0; i < els.length; i++) {
els[i].className = els[i].className.replace(/ *\bno-js\b/g, "js");
}
@jelmerdemaat
jelmerdemaat / index.html
Created November 14, 2012 08:59
A CodePen by Jelmer.
<div class="wrapper">
<div>This can be anything.</div>
<div>This can be anything.</div>
<div>This can be anything.</div>
<div>This can be anything.</div>
</div>
@jelmerdemaat
jelmerdemaat / gist:4107273
Created November 18, 2012 20:37
JavaScript hasClass, addClass, removeClass
// JavaScript hasClass, addClass, removeClass
//source: http://www.avoid.org/?p=78
function hasClass(el, name) {
return new RegExp('(\\s|^)'+name+'(\\s|$)').test(el.className);
}
function addClass(el, name)
{
if (!hasClass(el, name)) { el.className += (el.className ? ' ' : '') +name; }
@jelmerdemaat
jelmerdemaat / .gitignore
Last active December 15, 2015 01:39
General .gitignore rules
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #