Home arrow Style Sheets arrow Page 4 - Dynamic Galleries with DOM and CSS
STYLE SHEETS

Dynamic Galleries with DOM and CSS


Thumbnail galleries are one of the first things that made the Web surfing experience more interesting. These are whole pages of preview images, which, when clicked on, became the big ones allowed for fast scanning of the image material on offer and easy access to selected pictures. Chris Heilmann shows you how to create and maintain a thumbnail gallery.

Author Info:
By: Chris Heilmann
Rating: 4 stars4 stars4 stars4 stars4 stars / 22
January 31, 2005
TABLE OF CONTENTS:
  1. · Dynamic Galleries with DOM and CSS
  2. · Basic Functionality of a Thumbnail Gallery
  3. · Old School Dynamic Galleries
  4. · Sketching our Gallery
  5. · The Javascript
  6. · The Stylesheet
  7. · A Sequential Gallery
  8. · Other options

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Dynamic Galleries with DOM and CSS - Sketching our Gallery
(Page 4 of 8 )

 

The gallery we are about to create should have the following features: 

  • Clean, simple markup – The HTML developer should not need to add any extra information for our gallery to work.

  • Full accessibility – Users without Javascript should simply get the linked picture displayed in the browser. 
The HTML Markup 

In order to make scripts work without inline event calls, we need to use the Document Object Model (DOM) to reach what we want to enhance. To avoid extensive searching in the document, we wrap our gallery in an element with a certain ID, for example “thumbs.”  Each thumbnail will be contained in its own DIV, to allow for captions, should we want them, and is linked to the main image. 

<div id=”thumbs”>

    <div>

<a href="images/archway.jpg"><img src="images/tn_archway.jpg" alt="Archway with natural green roof" /></a>

</div>

</div> 

You might wonder why we don’t use a table for a thumbnail gallery, as technically a gallery with captions could be seen as tabular data. Furthermore a table degrades as a grid layout in non-CSS capable browsers, and our example shows up as one thumb under the other in those. The reason is that it is easier to maintain, renders faster and could be designed as liquid, something you cannot do with a table.

The script we are about to create can take both, so if you feel more comfortable using tables, go for it. 

In terms of accessibility, our example is perfectly acceptable. The nature of thumbnail galleries makes them not much use to blind or text browser users, but by giving the thumbnails a proper alternative text, even those users know what is linked. We could add a title to the links stating that it links to an image, though. Keyboard users have no problem with the gallery either –- they can tab from link to link (or press A in Opera), and hit enter to load the image. Pressing “Ctrl + Cursor Left” gets them back to the gallery. 


blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...
- CSS3 Animated Image Gallery: Transitions
- CSS3 Properties: Fixed Heights with box-sizi...
- CSS3 Properties: Altering Strokes and 3D Eff...
- CSS3 Properties: Text-Stroke
- CSS3 Transitions: Width and Height Properties
- Creating a Drop Down Menu in CSS3
- Intro to CSS Transitions

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials