jQuery Plugin For Creating An Image Grid with Dropdown Layers
File Size: | 156 KB |
---|---|
Views Total: | 3556 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
A tiny jQuery plugin for creating a responsive neat grid layout with dropdown layer boxes displaying more details about your images.
How to use it:
1. Include jQuery Javascript library and the jQuery Dropdown Layer plugin in the web page.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="js/dropdownLayer.js"></script>
2. Create an image grid with dropdown layers following the Html structure like this:
<div class="container"> <div class="persons js-dropdown-items"> <div class="person js-dropdown-item"> <div class="avatar"><img src="1.jpg" alt="" title="Title 1"></div> <div class="fullname">Name 1</div> <div class="title">Title 1</div> <div class="js-description"> <p>Description 1</p> </div> </div> <div class="person js-dropdown-item"> <div class="avatar"><img src="2.jpg" alt="" title="Title 2"></div> <div class="fullname">Name 2</div> <div class="title">Title 2</div> <div class="js-description"> <p>Description 2</p> </div> </div> <div class="person js-dropdown-item"> <div class="avatar"><img src="3.jpg" alt="" title="Title 3"></div> <div class="fullname">Name 3</div> <div class="title">Title 3</div> <div class="js-description"> <p>Description 3</p> </div> </div> ... </div> </div>
3. The required CSS styles. Add the following CSS snippet into you CSS file or include the main.css
directly in your document.
* { box-sizing: border-box; } body { background-color: #fff; color: #333; margin: 0; min-height: 100%; } .container { width: 100%; } .persons { padding: 40px 0 20px; max-width: 1000px; margin: 0 auto; position: relative; } .persons:before, .persons:after { clear: both; content: " "; display: table; } .persons .person { width: 25%; margin-bottom: 20px; display: table; float: left; border-left: 20px solid transparent; cursor: pointer; } .persons .person .avatar { width: 100%; display: block; text-align: center; } .persons .person .avatar img { border: 24px solid #E5E5E5; display: inline-block; width: 100%; vertical-align: middle; } .persons .person.active .avatar img { border-color: #323A45; } .persons .person .fullname { width: 100%; display: block; text-align: center; font-family: Raleway, sans-serif; color: #828282; font-size: 20px; padding: 10px 0 5px; } .persons .person .title { width: 100%; display: block; text-align: center; font-family: Raleway, sans-serif; color: #828282; font-size: 16px; } .persons .person .js-description { display: none; } @media screen and (max-width: 700px) { .persons .person { width: 50%; } } @media screen and (max-width: 400px) { .persons .person { width: 100%; border-left: medium none; } } .persons .js-dropdown { background-clip: padding-box !important; border: 0 solid transparent; box-sizing: border-box; float: left; padding: 0; margin: 40px 0 20px; width: 100%; display: table; border-color: transparent; border-image: none; border-style: solid; border-width: 0 0 10px 20px; } .persons .js-dropdown:before, .persons .js-dropdown:after { clear: both; content: " "; display: table; } @media screen and (max-width: 400px) { .persons .js-dropdown { border-left: medium none; } } .persons .js-dropdown .js-dropdown-content { background: none repeat scroll 0 0 #FFFFFF; border: 6px solid #E5E5E5; color: #333333; position: relative; width: 100%; padding: 48px 32px 0; } .persons .js-dropdown .js-dropdown-content .js-dropdown-arrow { position: absolute; bottom: 100%; left: 50%; width: 0; height: 0; margin-left: -55px; border: 46px solid transparent; border-bottom-color: #E5E5E5; pointer-events: none; -webkit-transition: left 0.3s; -moz-transition: left 0.3s; transition: left 0.3s; } .persons .js-dropdown .js-dropdown-content p { line-height: 26px; margin: 0 0 40px; padding: 0; font-size: 16px; }
4. Call the function to enable the plugin.
$(document).ready(function() { $('.js-dropdown-item').dropdownLayer(); });
5. Options and defaults.
'elemSelector': "js-dropdown-item", 'containerClass': "js-dropdown-items", 'descriptionClass': "js-description", 'dropdownClass': "js-dropdown", 'arrowClass': "js-dropdown-arrow", 'dropdownContentClass': "js-dropdown-content", 'disableDropdownClass': "js-dropdown-disable", 'slideUpSpeed': 300, 'slideDownSpeed': 300, 'useSlideDown': false, 'useSlideUp': false, 'transitionEffect': 'swing', 'callOnCompleteHide': function() {}, 'callOnCompleteShow': function() {}
Change log:
2015-11-28
- Added new options: 'slideUpSpeed', 'slideDownSpeed', 'useSlideDown','useSlideUp','transitionEffect','callOnCompleteHide', 'callOnCompleteShow'
This awesome jQuery plugin is developed by ViktorAksionov. For more Advanced Usages, please check the demo page or visit the official website.