Giter Club home page Giter Club logo

gridem's Introduction

jQuery Grid 'Em Plugin

This is a simple jQuery plugin that allows you to evenly apply horizontal spacing on a list of items across multiple rows on a page. Check out the demo site.

How to use this plugin

Both jQuery and Grid 'Em need to be included as a script on your page. Then simply target your list with gridem(). gridem() will apply the grid spacing to the direct children of the target. For example:

Say you had a list of items in an unordered list (ul).

<ul class="products">
  <li><div><img src="product.jpg"/><br/>Product title</li>
  <li><div><img src="product.jpg"/><br/>Product title</li>
  <li><div><img src="product.jpg"/><br/>Product title</li>
  ...
</ul>

Then you would simply call gridEm() as follows:

$(window).load(function() {
  $('.products').each(function() {
    $(this).gridEm();
});

In the above example, we iterated $('.product').each() which allows gridEm() to grid all lists on the page that have a class of product. For best results, it is recommended that you invoke gridEm() once the page has completely loaded as notified by $(window).load(). You can invoke gridEm() with $(document).ready() but the DOM might not be completely aware of all the page element dimensions yet.

Options

  • minMargin โ€” Minimum margin between items (in pixels) (default: 10)
  • maxMargin โ€” Maximum margin between items (in pixels) (default: 100)

For example:

$('.products').gridEm( { minMargin: 10, maxMargin: 50 } );

Compatibility

  • IE7 and above
  • Tested with the current versions of popular browsers: Firefox, Chrome, Safari and Opera

Limitations

This was created to display a grid of items which all items have the same width.

Contribute

Feel free to make improvements and submit pull requests.

Support

Please use the issues tracker on GitHub.

gridem's People

Contributors

ydagenais avatar

Watchers

Benjamin Slater 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.