Skip to content

Instantly share code, notes, and snippets.

@pixelhijack
pixelhijack / vertical align anything (IE9 too)
Created July 22, 2014 13:25
vertical align anything (IE9 too)
@mixin vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.element p {
@include vertical-align;
@pixelhijack
pixelhijack / no-js detection
Created July 17, 2014 17:35
no-js detection
<html class="no-js">
<head>
<!-- no-js detection -->
<script>(function(e,t,n){var r=e.querySelectorAll("html")[0];r.className=r.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")})(document,window,0);</script><!-- remove this if you are using Modernizr -->
</head>
<!-- add a class .no-js and remove if there's js. (~ Modernizr ) -->
</html>
@pixelhijack
pixelhijack / log() - console.log lightweight wrapper by Paul Irish
Created July 4, 2014 12:23
log() - console.log lightweight wrapper by Paul Irish
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
};
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
/* delay-in: 0s, delay-out: 5s */
.flyout{
display: block;
position: fixed;
width: 200px;
height: 90%;
top:68px;
left:-180px;
-webkit-transition: all .4s 5s cubic-bezier(0.175, 0.885, 0.320, 1.275);
.you-cant-touch-this{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
//==============================
//JAVASCRIPT @MEDIA QUERIES
//================================
var widthMax832px = window.matchMedia('(max-width: 832px)');
console.log('widthMax832px: ', widthMax832px);
//always check if window.matchMedia exist (older IE can crash on this. If still needed, use Paul Irish polyfill)
if(window.matchMedia && window.matchMedia("(max-width: 1201px)").matches) {
/*==============================
BROWSER DETECTION
================================
quick: console.log(/WebKit/.test(navigator.userAgent)) */
function getBrowser(){
var ua = window.navigator.userAgent.toLowerCase();
var ver = window.navigator.appVersion.toLowerCase();
var name = 'unknown';
.product-page dl{
overflow: hidden;
width:100%;
}
.product-page dt{
width: 30%;
font-weight: bold;
}
.product-page dd{
width: 70%;
/*
Raphael.js: find the center of element
*/
// element = paper.rect(......);
var cX = element.getBBox().x + element.getBBox().width/2,
cY = element.getBBox().y + element.getBBox().height/2;