Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I like Kotlin

Nicola Zanon zanonnicola

💭
I like Kotlin
View GitHub Profile
@zanonnicola
zanonnicola / center.css
Last active Dec 27, 2015 — forked from YohannParis/center.css
CSS: centering
View center.css
/*
* To horizontally and vertically center an element in css:
* http://css-tricks.com/centering-percentage-widthheight-elements/
*/
.center {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
@zanonnicola
zanonnicola / gist:7282497
Last active Dec 27, 2015 — forked from padolsey/gist:527683
JavaScript: detect IE
View gist:7282497
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
View lineargradienttest.js
/*
Modernizr already has a test for cssgradients but it checks the old webkit syntax
In order to do px points we need linear-gradient()
Webkit did not have suport for linear-gradient() until Jan 2011
http://webkit.org/blog/1424/css3-gradients/
So here is a test to check for it.
*/
Modernizr.addTest('lineargradient', function () {
var test = document.createElement('div'),
View Simple-Sticky-Menu.markdown

Simple Sticky Menu

A simple sticky menu with auto updating classes based on elements position.

A Pen by Nicola Zanon on CodePen.

License.

#ToDo:

@zanonnicola
zanonnicola / asyncLoading
Created Nov 18, 2013
Downloading JavaScript Files in Parallel. Script by: Rakesh Pai http://blog.rakeshpai.me/2009/03/downloading-javascript-files-in.html
View asyncLoading
<script type="text/javascript">
(function() {
var s = [
"/javascripts/script1.js",
"/javascripts/script2.js",
"/javascripts/script3.js",
"/javascripts/script4.js",
"/javascripts/script5.js"
];
View gist:7988654

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
View template.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
<style>
@media only screen and (min-device-width: 541px) {
.content {
View LICENSE.txt
DO WHAT YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Eli Perelman <http://eliperelman.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT YOU WANT TO PUBLIC LICENSE
@zanonnicola
zanonnicola / modernizr-sass.scss
Last active Aug 29, 2015
Modernizr and js/no-js mixins for Sass
View modernizr-sass.scss
// Taken from: http://codepen.io/sturobson/pen/xcdha
// Modernizr mixin to create html.modernizr selector
@mixin modernizr($test, $no: true) {
// if false then give the html.no-modernizr selector
@if $no == true {
html.no-#{$test} & {
@content;
}
}
@zanonnicola
zanonnicola / cookie.js
Created Apr 10, 2014
Set, read and erase Cokkies
View cookie.js