GithubHelp home page GithubHelp logo

acusti / retina-compass-helpers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joelambert/retina-compass-helpers

0.0 3.0 0.0 112 KB

Helper mixins to automatically add CSS for double dimension images

Ruby 52.16% CSS 47.84%

retina-compass-helpers's Introduction

Retina graphic helper for Compass

This is a quick helper function to make it easier to maintain regular and retina images in web sites/apps.

How to use

It works on a similar principle to how XCode manages images for iOS development. If you have an image called icon.png, first add another image with twice the height and width to the same directory and call it [email protected].

Next use the helper mixin provided by this extension:

@include background-image-retina('icon.png');

At its simplest this will generate:

background-image: url('icon.png?1323184535');

But if you also have the @2x image it will generate the require CSS (and a wrapping media query) to provide support for the double size graphics as well:

background-size: 50% auto;
background-image: url('[email protected]?1323184535');

There is also a second helper mixin to inline the images instead of link to them:

@include inline-background-image-retina('icon.png');

Both functions first check for the existence of the @2x graphics and won't fall over if they don't exist, it just won't output the retina CSS.

Install

  1. Move the folder containing this README into your compass directory (rename it to retina)

  2. Add the following to your config.rb

    retina_ext = File.join(File.dirname(__FILE__), 'retina')
    require File.join(retina_ext, 'lib', 'sass_extensions.rb')
    add_import_path File.join(retina_ext, 'stylesheets')
    
  3. Import the mixins into your stylesheet

    @import "retina";
    

License

Code is Copyright © 2012 Joe Lambert and is licensed under the terms of the MIT License.

retina-compass-helpers's People

Contributors

joelambert avatar acusti avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.