Sign up FAST! Login

5 Essential CSS, Javascript, and HTML Snippets for Front-end Developers | Image Conscious Studios


Stashed in:

To save this post, select a stash from drop-down menu or type in a new one:

Perfect Full-Page Background Images.cover {  background: url(images/bg.jpg) no-repeat center center fixed;  -webkit-background-size: cover;  -moz-background-size: cover;  -o-background-size: cover;  background-size: cover;}

Javascript Function Suicide

var yourFunction = function () {  // do stuff  yourFunction = function() {return false;}};

jQuery Placeholder Polyfill

jQuery(document).ready(function() {  jQuery.fn.cleardefault = function() {    return this.focus(function() {    if( this.value == this.defaultValue ) {this.value = “”;}  }).blur(function() {    if( !this.value.length ) {this.value = this.defaultValue;}  });};jQuery(“input, textarea”).cleardefault();

});

CSS 100% Height

.fullheight {  position: absolute;  top: 0;  bottom: 0;}

jQuery Scroll Events

$(window).on(“scroll resize”, function(){  var pos=$(‘#date’).offset();  $(‘.post’).each(function(){  if(pos.top >= $(this).offset().top && pos.top <= $(this).next().offset().top) {    $('#date').html($(this).html());    return; //break the loop  }  });});

$(document).ready(function(){$(window).trigger('scroll'); // init the value});

You May Also Like: