“How to Build an Accordion Image Gallery with only CSS” plus 1 more - Speckyboy Design Magazine Feed |
| How to Build an Accordion Image Gallery with only CSS Posted: 26 Apr 2012 12:15 AM PDT Fluent animated transitions for sliding web page elements such as a menu or an image gallery, have always traditionally been implemented with JavaScript. But using the CSS3 pseudo-class In the following CSS workshop we will build an accordion/toggler image gallery to show you how all it all works! This is what we will build… …and you can also have a quick look at the Demo before we start. Lets get started… The HTML structureGetting started, the basic HTML structure of the image gallery has three left menu items, consisting of an header element <ul class="imageMenu"> <li id="tasmania01"> <h2><a href="#tasmania01">Tasmania 01</a></h2> <p><span>Place: Tasmania, Date: 2008, Name: Tasmania 01, ...</span></p> </li> <li id="tasmania02"> <h2><a href="#tasmania02">Tasmania 02</a></h2> <p><span>Place: Tasmania, Date: 2008, Name: Tasmania 02, ...</span></p> </li> <li id="tasmania03"> <h2><a href="#tasmania03">Tasmania 03</a></h2> <p><span>Place: Tasmania, Date: 2008, Name: Tasmania 03, ...</span></p> </li> </ul> These Elements include the description of the menu item, which will, when clicked, be visible. The HTML above does look pretty poor without any CSS. Here is how it looks at the moment: Image Gallery Toggler without CSS Now it’s time for the CSS. Designing the inactive menu itemsWe will hide the content of the menu items by using the selector .imageMenu:not(:target) h2 a { background: rgb(54,86,94);/* Fallback */ background: rgba(0,0,0,.3); }Image Gallery Toggler with closed (inactive) items Designing the active menu itemsThe .imageMenu h2 a { display: block; font-size: 18px; font-weight: normal; color:#FFF; text-decoration:none; margin:0; padding:10px; background:rgb(54,86,94); background:rgba(255,255,255,.3); }The pseudo-class The pseudo-classes . imageMenu h2 a:hover, .imageMenu h2 a:active, .imageMenu h2 a:focus { background:rgb(154,186,194);/* Fallback */ background:rgba(255,255,255,.3); }The three possible states Here is what we have so far: Image Gallery Toggler with closed items and a focused menu item (“Tasmania 01″) Show me the images!The pseudo-classes .imageMenu:not(:target) p { padding:0; margin:0; height:0; overflow: hidden; }The images of the gallery are shown using the .imageMenu #tasmania01 p, .imageMenu #tasmania02 p, .imageMenu #tasmania03 p { background: url(.../images/tasmania01.jpg) top left no-repeat; position:relative; } .imageMenu #tasmania02 p { background-image: url(.../images/tasmania02.jpg); } .imageMenu #tasmania03 p { background-image: url(.../images/tasmania03.jpg); }The photographs we used for this tutorial were taken by the photographer Martin Neuhof from Leipzig, Germany. Now it’s time to define the “active state” of the menu items of this image gallery. The inactive item has no height, the active state needs a height – a real height. Therefore you have to define a height so that you can view the galleries background images. The images are 130px in height therefore we will need the same height for the paragraph. .imageMenu p { height:130px; }The result will be an opened menu item. Image Gallery Toggler with opend menu item (“Tasmania 01″) Preparing the toggle effectNow it’s time to toggle! The CSS3 Transition Module allows for the kind of flowing animated transition we need to create the toggle. The duration is set on 1.5 seconds. . imageMenu:not(:target) p { -moz-transition: height 1.5s ease-in; -webkit-transition: height 1.5s ease-in; -o-transition: height 1.5s ease-in; transition: height 1.5s ease-in; }Image Gallery Toggler with opend menu item (“Tasmania 01″) The open- and close-effect will work in IE9, but not the toggle-effect. All older versions of IE will ignore the pseudo-classes Image Gallery Toggler as seen by older versions of IE. If you try this CSS3 Workshop without the pseudo-classes Finished!Here is the finished gallery: You might also like…Scroll to Internal Link with jQuery → |
| We have 20 Pro Licenses for EasyRotator to Give Away Posted: 25 Apr 2012 07:52 AM PDT Today, we want to introduce you to a new WordPress plugin for creating sliders, EasyRotator for WordPress. The standard version of the plugin is free, but we’re giving you a chance to win the Pro version that includes additional templates and features. We have twenty prizes to give away, each worth $20! Check out this video to learn more about EasyRotator for WordPress: You can find instructions for installing the plugin on the DWUser.com site. How To EnterYou’ll probably want to first install the plugin – but you don’t have to. All you need to do is comment below, telling how you would use EasyRotator Pro on your WordPress website. Bonus EntriesWant to double or triple your chances of winning? Just tweet this contest page or share it on Facebook.
The DetailsThe contest closes on May 2, 2012. Winners will be selected completely at random and notified by email within a few days after the competition ends. Good luck! |
| You are subscribed to email updates from Speckyboy Design Magazine To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
| Google Inc., 20 West Kinzie, Chicago IL USA 60610 | |
Keine Kommentare:
Kommentar veröffentlichen