Skip to content

Instantly share code, notes, and snippets.

@kapitancho
kapitancho / inline-block.html
Created July 19, 2012 13:48
Cross-browser use of inline-block with spacing issues resolved for any font-family and font-size
<!DOCTYPE html>
<html>
<head>
<style>
html, body {
margin: 0;
padding: 0;
font-size: 15px;
font-family: Arial;
overflow: hidden;
@kapitancho
kapitancho / gist:5099504
Created March 6, 2013 14:06
IE 6 and IE 7 solution for generated content. This example shows how to emulate generated content in IE6 and IE7. It shows how to use content:attr (attribute name) and content : 'some text' and how to style the generated elements. Known issues: As the example below shows, a skew transition is applied to an element and to a :before element. Unfor…
<!DOCTYPE html>
<html>
<head>
<style>
.test {
background: red;
zoom: expression(
this.runtimeStyle.zoom="1",
this.insertBefore( document.createElement("before"), this.firstChild ).innerHTML = this.getAttribute ('data-for-before'),
this.appendChild( document.createElement("after") ).innerHTML = ' after-content '
@kapitancho
kapitancho / demo.html
Created March 21, 2013 10:30
Rotate an image in a canvas
<!DOCTYPE html>
<html lang="en">
<head>
<style>
* {
margin: 0;
padding: 0;
}
canvas {
outline: solid 1px black;
@kapitancho
kapitancho / nodeclick.html
Created October 17, 2015 11:19
Nodeclick mini function
<!DOCTYPE html>
<html>
<head>
<script>
//Add a single event listener that handles one or more actions based on the data-* attributes.
var nodeclick = function (container, mapping, omitHref) {
container.addEventListener ('click', function(event) {
var el = event.target;
while (el != container) {
if (el.href && omitHref !== false) return;
@kapitancho
kapitancho / es6.js
Created December 24, 2015 00:21
RequireJS plugin for es6 + babel 6.
define(['module'], function (module) {
'use strict';
var fetchText = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function(evt) {
if (xhr.readyState === 4) {
callback(xhr.responseText);
}