Skip to content

Instantly share code, notes, and snippets.

@jhafner
jhafner / textcolumns.css
Created May 30, 2013 15:43
CSS Text Columns
#columns-3 {
text-align: justify;
-ms-column-count: 3;
-ms-column-gap: 12px;
-ms-column-rule: 1px solid #c4c8cc;
-moz-column-count: 3;
-moz-column-gap: 12px;
-moz-column-rule: 1px solid #c4c8cc;
-webkit-column-count: 3;
-webkit-column-gap: 12px;
@jhafner
jhafner / no-ios-highlights.css
Created May 30, 2013 15:50
Disable Mobile Webkit Highlights
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@jhafner
jhafner / absolute-centering.css
Created August 19, 2013 14:06
Absolute centering of elements with CSS. Advantages: Cross-browser (including IE8-10) No special markup, minimal styles Responsive with percentages and min-/max- Use one class to center any content Centered regardless of padding (without box-sizing!) Blocks can easily be resized Works great on images Caveats: Height must be declared Recommend se…
.Center-Container {
position: relative;
}
.Absolute-Center {
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
position: absolute;
@jhafner
jhafner / mobile-form.html
Created August 19, 2013 15:47
Describes HTML5 Attributes for Forms on Mobile Devices
<form id="mobile-form">
<input type="tel" /> <!-- Displays number pad -->
<input type="text" pattern="\d*" novalidate /> <!-- Displays number pad on text fields -->
<input type="email" autocapitalize="off" /> <!-- Displays email input, disables auto-capitalization -->
<input type="text" autocorrect="off" /> <!-- Disables autocorrect -->
</form>
@jhafner
jhafner / canvas-boilerplate.js
Created August 23, 2013 22:38
Canvas (2D) Boilerplate
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
function loop() {
clear();
update();
draw();
#!/usr/bin/env bash
# fresh-chrome
#
# Use this script on OS X to launch a new instance of Google Chrome
# with its own empty cache, cookies, and user configuration.
#
# The first time you run this script, it will launch a new Google
# Chrome instance with a permanent user-data directory, which you can
# customize below. Perform any initial setup you want to keep on every
@jhafner
jhafner / succinct-usage.js
Created September 18, 2013 18:20
A tiny jQuery plugin for truncating multiple lines of text.
$(function(){
$('.truncate').each(function(el){
var $this = $(this);
var t_size = $this.data('text-length');
$this.succinct({
size: t_size
});
});
});
// For adding icons to elements using CSS pseudo-elements
// Source: http://jaydenseric.dev/blog/fun-with-sass-and-font-icons
@mixin icon($position: 'before', $styles: true, $icon: false) {
// Either a :before or :after pseudo-element, defaulting to :before
&:#{$position} {
@if $icon {
// Icon has been specified
content: match($icons, $icon);
}
@if $styles {
@jhafner
jhafner / sass-mediaquery-mixin.scss
Created July 12, 2013 14:59
Sass Media Query Mixin
// Mixin Function
@mixin breakpoint($point) {
@if $point == desktop {
@media (max-width: 1600px) { @content; }
}
@else if $point == tablet {
@media (max-width: 1250px) { @content; }
}
@else if $point == handheld {
@media (max-width: 650px) { @content; }
@jhafner
jhafner / sass-grid.scss
Created July 11, 2013 14:52
Simple grid in Sass
/* Your variables */
$nb-columns : 6;
$wrap-width : 1140px;
$column-width : 180px;
/* Calculations */
$gutter-width : ($wrap-width - $nb-columns * $column-width) / $nb-columns;
$column-pct : ($column-width / $wrap-width) * 100;
$gutter-pct : ($gutter-width / $wrap-width) * 100;