Giter Club home page Giter Club logo

tailorfit's Introduction

TailorFit

jQuery plugin that fits and centers elements within their containers.

Tested on all user-agents available on Chrome 26 dev tools:

  • IE 7+

  • FF 4+

  • iOS 3+ (iPad and iPhone)

  • Android

  • BlackBerry

  • MeeGo

  • Screenshots of tests done on browsershots.org:

Latest version will always be hosted at

http://dev.fhmp.net/tailorfit/tailorfit-latest.min.js

Usage

    $('#parent > img').load(function(){
        // maxWidth, maxHeight, maintain aspect ratio
        $(this).tailorfit({
                maxWidth  : this.width,
                maxHeight : this.height,
                ratio     : this.width / this.height
        });
    });

You can also use expressions to evaluate a value.

For example: max-width: 0.8*w-(200-h/4) or max-width: h / 2 - 20, where w and h are the parent's width and height.

Note: (expr) = expression, using (w, h, +, -, *, /, ^, %)

Available options:

  • max-width (expr)
  • max-height (expr)
  • aspect-ratio (expr)
  • x-offset (expr)
  • y-offset (expr)
  • h-position (left | center | right)
  • v-position (top | center | bottom)
  • rounding-method (round | floor | ceiling)
  • overflow (contain | crop)

tailorfit's People

Contributors

rtheunissen avatar

Watchers

James Cloos avatar idrisjafer 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.