Code Monkey home page Code Monkey logo

iron-image's Introduction

Build status

Demo and API docs

##<iron-image>

iron-image is an element for displaying an image that provides useful sizing and preloading options not found on the standard <img> tag.

The sizing option allows the image to be either cropped (cover) or letterboxed (contain) to fill a fixed user-size placed on the element.

The preload option prevents the browser from rendering the image until the image is fully loaded. In the interim, either the element's CSS background-color can be be used as the placeholder, or the placeholder property can be set to a URL (preferably a data-URI, for instant rendering) for an placeholder image.

The fade option (only valid when preload is set) will cause the placeholder image/color to be faded out once the image is rendered.

Examples:

Basically identical to <img src="..."> tag:

<iron-image src="http://lorempixel.com/400/400"></iron-image>

Will letterbox the image to fit:

<iron-image style="width:400px; height:400px;" sizing="contain"
  src="http://lorempixel.com/600/400"></iron-image>

Will crop the image to fit:

<iron-image style="width:400px; height:400px;" sizing="cover"
  src="http://lorempixel.com/600/400"></iron-image>

Will show light-gray background until the image loads:

<iron-image style="width:400px; height:400px; background-color: lightgray;"
  sizing="cover" preload src="http://lorempixel.com/600/400"></iron-image>

Will show a base-64 encoded placeholder image until the image loads:

<iron-image style="width:400px; height:400px;" placeholder="data:image/gif;base64,..."
  sizing="cover" preload src="http://lorempixel.com/600/400"></iron-image>

Will fade the light-gray background out once the image is loaded:

<iron-image style="width:400px; height:400px; background-color: lightgray;"
  sizing="cover" preload fade src="http://lorempixel.com/600/400"></iron-image>
Custom property Description Default
--iron-image-placeholder Mixin applied to #placeholder {}
--iron-image-width Sets the width of the wrapped image auto
--iron-image-height Sets the height of the wrapped image auto

iron-image's People

Contributors

bicknellr avatar tedium-bot avatar kevinpschaaf avatar cdata avatar dfreedm avatar rictic avatar jklein24 avatar notwaldorf avatar garlicnation avatar blasten avatar abdonrd avatar westbrook avatar opus1269 avatar keanulee avatar tyriar avatar ebidel avatar fredj avatar marvinrichter avatar tjsavage avatar yufengg avatar herbalizer404 avatar

Watchers

 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.