background preloader

CSS Sprites: What They Are, Why They're Cool, and How To Use Them

CSS Sprites: What They Are, Why They're Cool, and How To Use Them
By Chris Coyier On This article has been revised and re-written several times since its very first publication in 2007, to keep the information current. The most recent revision was done by Flip Stewart in January 2015. #What are CSS Sprites? Spoiler alert: they aren't fairies that write your stylesheets for you. To summarize: the term "sprites" comes from a technique in computer graphics, most often used in video games. CSS Sprites is pretty much the exact same theory: get the image once, and shift it around and only display parts of it. #Why use CSS Sprites? It may seem counterintuitive to cram smaller images into a larger image. Let's look at some numbers on an actual example: That adds up to a total of 14.38KB to load the three images. While the total image size (sometimes) goes up with sprites, several images are loaded with a single HTTP request. Thus, sprites are important for the same reasons that minifying and concatinating CSS and JavaScript are important. $ npm install sprity -g

SpriteMe CSS Tools: Reset CSS The goal of a reset stylesheet is to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings, and so on. The general reasoning behind this was discussed in a May 2007 post, if you're interested. Reset styles quite often appear in CSS frameworks, and the original "meyerweb reset" found its way into Blueprint, among others. The reset styles given here are intentionally very generic. There isn't any default color or background set for the body element, for example. I don't particularly recommend that you just use this in its unaltered state in your own projects. In other words, this is a starting point, not a self-contained black box of no-touchiness. If you want to use my reset styles, then feel free! Previous Versions v1.0 (200802) Acknowledgments Thanks to Paul Chaplin for the blockquote / q rules.

Offline.js – Handle your users losing their internet connection like a pro What is Offline.js? Offline.js is a library to automatically alert your users when they've lost internet connectivity, like Gmail. It captures AJAX requests which were made while the connection was down, and remakes them when it's back up, so your app reacts perfectly. It has a number of beautiful themes and requires no configuration. Install The easiest way to add Offline to your site is with Eager. Click Install to see a live preview of Offline on your website. Download Offline.js Pick a Theme Indicator Themes Submit a theme! Documentation HubSpot

CSS code structure for HTML 5: some useful guidelines In this post I want to illustrate some useful guidelines about how to implement a well organized CSS code structure in view of introduction of HTML 5 markup language. They are not general rules but simple suggestions you can follow in order to improve the readability, manageability, and general organization of CSS code. These suggestions are especially useful if you have to work on complex CSS files that otherwise can be difficult to manage. I prefer to separate CSS code in three distinct sections: a first section that contains general HTML tags; a second section that contains structure tags; a last section with custom classes. Section 1: General HTML tagsIn this section I divide the code in two subsections. Section 1: Subsection 1How you know, regarding CSS reset, this practice is used to reset default browser styles for HTML standard elements (body, h1, p, ul, li, ...). border:0;margin:0;padding:0;font-size:100%;... /* Subsection 2: Standard HTML tags redefinition */body, form, input {

Bitcoin, Litecoin : montez votre propre mineur ! : Composants informatique Book - Scalable and Modular Architecture for CSS I have long lost count of how many web sites I’ve built. You would think after having built a few hundred of them I would have discovered the “one true way” of doing it. I don’t think there is one true way. What I have discovered are techniques that can keep CSS more organized and more structured, leading to code that is easier to build and easier to maintain. I have been analyzing my process (and the process of those around me) and figuring out how best to structure code for projects on a larger scale. SMACSS (pronounced “smacks”) is more style guide than rigid framework. Inspiration In trying to learn more about what does and doesn't work in maintaining larger projects, I looked at how others were trying to solve similar problems. What’s in here? My thoughts have been compartmentalized around a number of topics related to CSS architecture. Now get started and dive in!

AngularJS Best Practices: I’ve Been Doing It Wrong! Part 2 of 3 | Art & Logic Blog Three sanity-preserving ideas that will make me and you 10x more productive with real-world AngularJS applications This is the second in a three-part series on practical large-scale development with AngularJS. The TL;DR version is at the end of the article. If you have not read the first part, you might want to start with it. It lays out the foundation for the structure of a large-scale AngularJS project. Part 2: Enjoyable Automated Testing Automatic testing is easy, natural, and helpful. Like any undesirable habit, the habit of not-testing-the-code can be fixed if tests are an integral part of our coding routine, and they get executed and checked without any conscious effort on our part. So, what does Karma do for you? Thanks to integration with Grunt, every time you modify a file, the test suite gets a re-run, and test results are regenerated. The official documentation says it best. How do I write my tests? It depends on your favourite testing framework. Unit Tests Happy testing!

jReject - jQuery Plugin for Simple Browser Rejection Grunt: Automated Testing With a look into our evolving JavaScript testing methods, Patrick shares how we're using Mocha, Jasmine, and Grunt. Introduction A few months ago we posted about our new build process, and we mentioned starting to use Grunt for the “freedom and customization” that it provided. In addition, we noted that we're using the Jasmine plugin, which allows for JavaScript testing. Recently, Rob Tarr released a new application called Stuntman. This application (using node.js) had the need for both client and server-side JavaScript testing. Grunt to the Rescue Running both server and client-side JavaScript specs was an issue. Our solution: Test client side JavaScript with Jasmine Test our server side JavaScript with Mocha Not very challenging to do thanks to Grunt, but there are some important packages you will need. Prerequisites Grunt Setup Check out the example repository. Our basic setup consists of the following packages in our package.json file: Example “package.json” Gruntfile.js Setup npm install or

ImagesLoaded JavaScript is all like "You images done yet or what?" imagesloaded.desandro.com Detect when images have been loaded. Demo Edit this example on CodePen or try the jQuery example. Just to keep things interesting, there’s a 10% chance of adding a broken image. Install Get a packaged source file: Or install via Bower: bower install imagesloaded Or install via Component: component install desandro/imagesloaded Usage imagesLoaded( elem, callback ) new imagesLoaded( elem, callback ) elem Element, NodeList, Array, or Selector Stringcallback Function - function triggered after all images have been loaded Using a callback function is the same as binding it to the always event (see below). imagesLoaded( document.querySelector('#container'), function( instance ) { console.log('all images are loaded'); }); imagesLoaded( '#container', function() {...}); var posts = document.querySelectorAll('.post'); imagesLoaded( posts, function() { Events imagesLoaded is an Event Emitter. always done fail progress Properties jQuery

Related: