Giter VIP home page Giter VIP logo

superbox's Introduction

Superbox

The lightbox, reimagined

SuperBox takes the whole 'image' and 'lightbox' one step further, reducing the JavaScript and image load dependence to make lightboxing a thing of the past! Using HTML5 data-* attributes, responsive layouts and jQuery, here's SuperBox.

SuperBox works wonders as a static image gallery, which you can click to reveal a full version of the image. Each image in the demo is the same size, but SuperBox supports any image size.

Demo

You can view the v3 demo here.

Instructions

  1. Include jQuery in your page (likely just before the body tag).

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  2. Include the superbox plugin just after the call to jQuery.

    <script src="js/jquery.superbox.js"></script>
  3. Include the other superbox assets (css, images, etc...) accordingly.

    <link href="css/superbox.css" rel="stylesheet">
  4. Add a div to your markup with a class or id that suits your needs. For example:

    <div class="MyGalley">
    </div>
  5. Inside the div you created in step 1, add div and image pairs that contain your thumbnail images (square are best, but whatever the case be sure to make them all the same size and orientation). For example:

    <div>
        <img src="img/thumb-1.jpg" data-img="img/full-1.jpg" alt="">
    </div>

    Add as many of these as your gallery requires, one after the other. All together it should look like this:

    <div class="MyGalley">
    	<div>
    	    <img src="img/thumb-1.jpg" data-img="img/full-1.jpg" alt="">
    	</div>
    	<div>
    	    <img src="img/thumb-2.jpg" data-img="img/full-2.jpg" alt="">
    	</div>
    	<div>
    	    <img src="img/thumb-3.jpg" data-img="img/full-3.jpg" alt="">
    	</div>
    	<div>
    	    <img src="img/thumb-4.jpg" data-img="img/full-4.jpg" alt="">
    	</div>
    	<div>
    	    <img src="img/thumb-5.jpg" data-img="img/full-5.jpg" alt="">
    	</div>
    	<div>
    	    <img src="img/thumb-6.jpg" data-img="img/full-6.jpg" alt="">
    	</div>
    	<div>
    	    <img src="img/thumb-7.jpg" data-img="img/full-7.jpg" alt="">
    	</div>
    	<div>
    	    <img src="img/thumb-8.jpg" data-img="img/full-8.jpg" alt="">
    	</div>
    </div>
  6. Invoke superbox on the gallery div. It's best to do this on document ready or some such handler. For example:

    <script>
    $(function() {
    	$('.MyGallery').SuperBox();
    });
    </script>

Options

$.SuperBox({
	background : '#FF0000', // Full image background color. Default: #333
	border : 'white', // Full image border color. Default: #222
	height : 600, // Maximum full image height. Default: 400
	view : 'landscape|square|portrait', // Sets ratio on smaller viewports. Default: landscape
	xColor : '#CCC', // Close icon color. Default: #FFF
	xShadow : 'embed' // Close icon shadow. Default: none
});

HTML5 data-* attributes

SuperBox feeds off the data-img custom attribute I've added to display the full image, this means we don't have to rely on more markup as it dynamically appends the data-img source for you.

Responsive

SuperBox is also responsive, allowing you to use it across any device. The media queries are really basic so you can build and expand upon it to fit within your project.

Keyboard navigation

Superbox allows your viewers to arrow through your image gallery.

Browser support

Works on all modern browsers, IE8 and above.

superbox's People

Contributors

seydoggy avatar macsupport avatar toddmotto avatar

Watchers

jadeye 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.