SlideShare a Scribd company logo
Search
ASP
CSS
DHTML
HTML
JavaScript
Perl
PHP
RSS
XHTML
XML
3D Modeling
Design
Design Lab
Graphics
HTML Tools
Internet
JavaScript Tools
Multimedia
Programming
Promotion
Reviews
Search Engine Resources
Video
Web Servers
Color Codes
HTML Characters
HTML Tags
JavaScript Core
Reference Section
Site Services
XML
[previous] [next]
Web Developer/Designer
Targus
US-CA-Anaheim
Post A Job | Post A Resume
tip archive • about • sitemap • contact • jobs • write
for us • subscribe
home | programming | css_gallery | How to Create a Photographic Gallery Using CSS /
Page 2
How to Create a Photographic Gallery Using CSS [con't]
My images are either
372px high by 240px
wide (portrait format) or
240px high by 372px
wide (landscape format).
These sizes have been
calculated for several
reasons, namely:
To enable the
gallery to fit within
a screen
resolution of 800 x
600 pixels without
the need for
scrolling.
1.
To give thumbnail
images of 93px by
60px (a quarter of
the full size),
which I consider to
be large enough to
give a good
preview of the full
size image.
2.
To enable me to
place three portrait
thumbnails OR two landscape thumbnails in a line using a border of 1 pixel and a
left / right margin of 2 pixels.
3.
A horizontal row of three portrait images, 60px wide, each one having a border of 1px
and a left / right margin of 2px gives a total width of 3 times 66px which is 198px.
A horizontal row of two landscape images, 93px wide, each one having a border of 1px
and a left / right margin of 2px gives a total width of 2 times 99px which is also 198px.
I find it best to sketch out a rough plan of the gallery before I begin to add the styling, this
way I can calculate the best size for my thumbnails and full size images. A little bit of
thought 'up front' will save a lot of frustration and redesign.
MARKETPLACE
Get Your Six Sigma Certification
Earn Villanova Six Sigma Certification 100% Online
Program -- FREE Info.
VillanovaU.com/SixSigma
With Less, Do More
Windows 7 Professional and the Windows Server
2008 Family
Microsoft.com/SmallBusiness
Internet Marketing Master's Degree
Learn Effective Internet Marketing Strategies While
Earning Your Masters Online!
www.FullSail.edu
IT Professionals Developers Solutions eBook Library Webopedia Login Register
Page 1 of 6How to Create a Photographic Gallery Using CSS / Page 2
8/17/2010http://www.webreference.com/programming/css_gallery/2.html
Newletters
Networking Daily
submit
Eclipse Helios Update Brings New
PHP Tools
Internet Explorer 9 Ups Standards
Support
JBoss Portal 5 Release Easier to
Use
Step 2
The !DOCTYPE
Firstly and most importantly, make sure that you have the correct (X)HTML !DOCTYPE.
Without this most browsers will be thrown into 'quirks' mode which will lead to all sorts of
incompatibility problems. W3C QA - List of valid DTDs has a list of valid DOCTYPES that
can be used. Select from XHTML1.0 or XHTML1.1 as these are more suitable for this
styling. I use XHTML1.1 for all my current web pages.
Step 3
Adding links and style information
In order that I can use the :hover pseudo class style I need to change the basic
unordered list into an unordered list of links. This is because Internet Explorer will only
allow :hover to be used on links. I also need to add extra markup to target specific
images.
The (x)html will now look like this:
1 <div id="container">
2 <ul>
3 <li>
4 <a class="gallery slidea" href="#nogo">
5 <span>
6 <img src="../images/p1.jpg" alt="Alpha" title="Alpha" />
7 <br />
8 ALPHA
9 <br />
10 Photographed by Dorota Mrowka, courtesy of the stock.xchng
11 </span>
12 </a>
13 </li>
14 <li>
15 <a class="gallery slideb" href="#nogo">
16 <span>
17 <img src="../images/p2.jpg" alt="Minie" title="Minie" />
18 <br />
19 MINIE
20 <br />
21 Photographed by José Antonio Assis, courtesy of the stock.xchng
22 </span>
23 </a>
24 </li>
25 <li>
26 <a class="gallery slidec" href="#nogo">
27 <span>
28 <img src="../images/p3.jpg" alt="Megan" title="Megan" />
29 <br />
30 MEGAN
31 <br />
32 Photographed by Rob Waterhouse, courtesy of the stock.xchng
33 </span>
34 </a>
35 </li>
36 <li>
37 <a class="gallery slided" href="#nogo">
38 <span>
39 <img src="../images/p4.jpg" alt="Nancy" title="Nancy" />
40 <br />
41 NANCY
42 <br />
43 Photographed by Philip Keller, courtesy of the stock.xchng
44 </span>
45 </a>
view plain | print | copy to clipboard | ?
Page 2 of 6How to Create a Photographic Gallery Using CSS / Page 2
8/17/2010http://www.webreference.com/programming/css_gallery/2.html
46 </li>
47 <li>
48 <a class="gallery slidee" href="#nogo">
49 <span><img src="../images/p5.jpg" alt="Missy" title="Missy" />
50 <br />
51 MISSY & PANDA
52 <br />
53 Photographed by Kat Shurtz, courtesy of the stock.xchng
54 </span>
55 </a>
56 </li>
57 <li>
58 <a class="gallery slidef" href="#nogo">
59 <span>
60 <img src="../images/p6.jpg" alt="Stray pup" title="Stray pup" />
61 <br />
62 STRAY PUP
63 <br />
64 Photographed by Bethan Hazell, courtesy of the stock.xchng
65 </span>
66 </a>
67 </li>
68 <li>
69 <a class="gallery slideg" href="#nogo">
70 <span>
71 <img src="../images/p7.jpg" alt="Rolo" title="Rolo" />
72 <br />
73 ROLO
74 <br />
75 Photographed by Paul Leach, courtesy of the stock.xchng
76 </span>
77 </a>
78 </li>
79 <li>
80 <a class="gallery slideh" href="#nogo">
81 <span>
82 <img src="../images/p8.jpg" alt="Gigio" title="Gigio" />
83 <br />
84 GIGIO
85 <br />
86 Photographed by Davide Guglielmo, courtesy of the stock.xchng
87 </span>
88 </a>
89 </li>
90 <li>
91 <a class="gallery slidei" href="#nogo">
92 <span>
93 <img src="../images/p9.jpg" alt="Westy pup" title="Westy Pup" />
94 <br />
95 WESTY PUP
96 <br />
97 Photographed by Rob Waterhouse, courtesy of the stock.xchng
98 </span>
99 </a>
100 </li>
101 <li>
102 <a class="gallery slidej" href="#nogo">
103 <span>
104 <img src="../images/p10.jpg" alt="Giga Byte" title="Fishing" />
105 <br />
106 GIGA BYTE
107 <br />
108 Photographed by Jefras, courtesy of the stock.xchng
109 </span>
110 </a>
111 </li>
112 <li>
113 <a class="gallery slidek" href="#nogo">
view plain | print | copy to clipboard | ?
Page 3 of 6How to Create a Photographic Gallery Using CSS / Page 2
8/17/2010http://www.webreference.com/programming/css_gallery/2.html
114 <span>
115 <img src="../images/p11.jpg" alt="Puppy" title="Puppy" />
116 <br />
117 PUPPY
118 <br />
119 Photographed by Clodiney Cruz, courtesy of the stock.xchng
120 </span>
121 </a>
122 </li>
123 <li>
124 <a class="gallery slidel" href="#nogo">
125 <span>
126 <img src="../images/p12.jpg" alt="Buffy" title="Buffy" />
127 <br />
128 BUFFY
129 <br />
130 Photographed by Rob Waterhouse, courtesy of the stock.xchng
131 </span>
132 </a>
133 </li>
134 </ul>
135 </div>
view plain | print | copy to clipboard | ?
‡ Style Ready List
Every list item is now enclosed in a link which has a common gallery class and a
unique slide letter class. They are also further enclosed by a span which does not
have any specific class or id.
I have used href="#nogo" instead of the more usual href="#" so that anyone
clicking the link will not jump to the top of the page (just make sure you do not have an
anchor #nogo on your page). You can, if you wish use this to link to take visitors to a
larger image on a new page.
The (x)html unordered list is now complete and I will not need to make any more
changes to it.
The Styling
Step 4
The body
The <body> is first to be styled with the font-family for the whole page. I have
chosen Tahoma as the first choice but you can select any font you wish. I have also
chosen a font size of 76% as this is gives a suitable default size for most screen
resolutions. It also allows Internet Explorer users to resize the font if they wish.
1 /* choose a suitable font and center the #container div in Internet Explorer */
2 body {
3 text-align:center;
4 font-family: tahoma; arial, sans-serif;
5 font-size:76%;
6 letter-spacing:0.05em;
7 }
view plain | print | copy to clipboard | ?
I have added text-align:center; so that Internet Explorer will place the
#container div centrally (left / right) on the page. This will only target Internet
Explorer and Opera, all other browsers will ignore this styling. I will use the 'correct
method' as described in Step 4 to target all other browsers.
Page 4 of 6How to Create a Photographic Gallery Using CSS / Page 2
8/17/2010http://www.webreference.com/programming/css_gallery/2.html
[previous] [next]
‡ Example #1
Step 5
The container
In order that the gallery can be viewed at a resolution of 800 x 600 I will limit the
#container div to a fixed size of 770px wide by 396px high. I will also add a 1px
thick grey border.
This is fairly straightforward to style as seen below:
1 /* The containing box for the gallery. */
2 #container {
3 position:relative;
4 width:770px;
5 height:396px;
6 margin:20px auto 0 auto;
7 border:1px solid #aaa;
8 }
view plain | print | copy to clipboard | ?
‡ Example #2
I have given this div a relative position so that I can position the gallery images within it
using absolute positions. The margins have been given a left / right value of auto so that
all browsers, except Internet Explorer (which has been taken care of in Step 3 above),
will center the div (left / right) on the page.
Depending on which browser you are using you will see either the images overflowing
the container or the images held within an expanded container. The 'correct'
interpretation is that the images should overflow the container.
Step 6
Removing the bullets
I will need to style the unordered list by removing the bullets and the indentation.
Browsers have different ways of doing this, Internet Explorer and Opera use margin
values for the indentation whereas Mozilla/Netscape/Firefox all use padding values, so to
cater for this I need to style the list as follows.
1 /* Removing the list bullets and indentation */
2 #container ul {
3 padding:0;
4 margin:0;
5 list-style-type:none;
6 }
view plain | print | copy to clipboard | ?
‡ Example #3
Now the bullets are gone.
home | programming | css_gallery | How to Create a Photographic Gallery Using CSS /
Page 2
Page 5 of 6How to Create a Photographic Gallery Using CSS / Page 2
8/17/2010http://www.webreference.com/programming/css_gallery/2.html
Add Multilingual Support to Your Java
Web Pages
Creating an ASP.NET Registration and
Confirmation System
Build Your Own PHP Web Mailer
MySQL in Amazon EC2 -
Beginners Guide
Spiceworks 5.0 Beta Adds New
Help Desk Features
7 Ways to Help Customers Trust
Your Ecommerce Website
The Network for Technology Professionals
Search:
About Internet.com
Copyright 2010 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers
Solutions
Whitepapers and eBooks
Helpful Cloud Computing Resources MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
User Experience Management Indicators for Business and IT Success
Ensuring Performance Meets Business and Web User Needs
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Get BlackBerry Enterprise Server Express for Free MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Demo: Google Site Search
Virtual Event: Master Essential Techniques for Leveraging the Cloud
Article: Explore Application Lifecycle Management Tools in Visual Studio 2010
Internet.com Hot List: Get the Inside Scoop on IT and Developer Products
New Security Solutions Using Intel(R) vPro(TM) Technology
All About Botnets
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
Page 6 of 6How to Create a Photographic Gallery Using CSS / Page 2
8/17/2010http://www.webreference.com/programming/css_gallery/2.html

More Related Content

PDF
Seven deadly theming sins
PDF
Why ExpressionEngine is Great for Designers
PDF
[O'Reilly] HTML5 Design
PDF
Wordpress Beyond Websites
PPT
jQuery For Beginners - jQuery Conference 2009
PPTX
Customizing WordPress Themes
PDF
JD17NL Joomla! Overrides and alternate layouts
PDF
How to make a WordPress theme
Seven deadly theming sins
Why ExpressionEngine is Great for Designers
[O'Reilly] HTML5 Design
Wordpress Beyond Websites
jQuery For Beginners - jQuery Conference 2009
Customizing WordPress Themes
JD17NL Joomla! Overrides and alternate layouts
How to make a WordPress theme

What's hot (20)

PDF
Game Development Using HTML 5
PPTX
iPhone Web Applications: HTML5, CSS3 & dev tips for iPhone development
PDF
HTML5 workshop, part 1
PDF
[edUi] HTML5 Workshop
PPTX
Rebrand WordPress Admin
PDF
Using HTML5 sensibly
PDF
jQuery UI and Plugins
PDF
Multimedia on the web - HTML5 video and audio
PDF
Dress Your WordPress with Child Themes
PDF
Implement rich snippets in your webshop
PDF
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
PDF
[heweb11] HTML5 Makeover
PDF
HTML5 and the web of tomorrow!
PDF
Speak The Web: The HTML5 Experiments
PDF
Installing And Configuration for your Wordpress blog
PDF
HTML5 and Accessibility sitting in a tree
PDF
Taiwan Web Standards Talk 2011
PDF
Performance as User Experience [AEADC 2018]
PPTX
WordPress and PHP - It Takes One to Know One
PPT
Game Development Using HTML 5
iPhone Web Applications: HTML5, CSS3 & dev tips for iPhone development
HTML5 workshop, part 1
[edUi] HTML5 Workshop
Rebrand WordPress Admin
Using HTML5 sensibly
jQuery UI and Plugins
Multimedia on the web - HTML5 video and audio
Dress Your WordPress with Child Themes
Implement rich snippets in your webshop
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
[heweb11] HTML5 Makeover
HTML5 and the web of tomorrow!
Speak The Web: The HTML5 Experiments
Installing And Configuration for your Wordpress blog
HTML5 and Accessibility sitting in a tree
Taiwan Web Standards Talk 2011
Performance as User Experience [AEADC 2018]
WordPress and PHP - It Takes One to Know One
Ad

Viewers also liked (7)

PDF
beca movilidad y material de estudio
PDF
beca devolucion de matricula
PDF
Module 10search engine optimization
PDF
Http _css-tricks
PDF
Seo continued page 2
PPT
Developing a mobile application curriculum which empowers authentic
PDF
Module11: Creating A External Style Sheet and Creating A Gallery
beca movilidad y material de estudio
beca devolucion de matricula
Module 10search engine optimization
Http _css-tricks
Seo continued page 2
Developing a mobile application curriculum which empowers authentic
Module11: Creating A External Style Sheet and Creating A Gallery
Ad

Similar to Css web gallery (20)

PPTX
Create Responsive Website Design with Bootstrap 3
PDF
Introduction to Responsive Design v.2
PDF
Responsive design
PDF
Web Accessibility for the 21st Century
KEY
Topsy Turvy Design
KEY
2022 HTML5: The future is now
PDF
Responsive Web Design - Drupal Camp CPH
KEY
RWD in the Wild
PDF
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
PDF
ViA Bootstrap 4
KEY
HTML5 apps for iOS (and probably beyond)
PDF
Adobe MAX 2008: HTML/CSS + Fireworks
KEY
Artdm171 Week4 Tags
KEY
Ease into HTML5 and CSS3
PDF
Web Design Bootcamp - Day1
PDF
HTML 5 Step By Step - Ebook
PDF
Class 4 handout two column layout w mobile web design
PPTX
Lect-4-Responsive-Web-06032024-082044am.pptx
PDF
Илья Пухальский (EPAM Systems)
PPTX
Accessibility Hacks version 2
Create Responsive Website Design with Bootstrap 3
Introduction to Responsive Design v.2
Responsive design
Web Accessibility for the 21st Century
Topsy Turvy Design
2022 HTML5: The future is now
Responsive Web Design - Drupal Camp CPH
RWD in the Wild
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
ViA Bootstrap 4
HTML5 apps for iOS (and probably beyond)
Adobe MAX 2008: HTML/CSS + Fireworks
Artdm171 Week4 Tags
Ease into HTML5 and CSS3
Web Design Bootcamp - Day1
HTML 5 Step By Step - Ebook
Class 4 handout two column layout w mobile web design
Lect-4-Responsive-Web-06032024-082044am.pptx
Илья Пухальский (EPAM Systems)
Accessibility Hacks version 2

More from Daniel Downs (20)

PDF
Ipad quick-reference-2
PDF
Index of jquery template 2 Minuteman Summer Web Dev.
PDF
Jquery template 1 3 pages
PDF
Module6 htmlcss helpfulcodeandwebsites
PDF
Module 4 Minuteman Lexington Web Design Daniel Downs
PDF
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
PDF
Module 2 lexington minuteman web development basic layout template
PDF
Module 1 Web design & Development Lexington Minuteman
PDF
App research project
PDF
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
PDF
Blogger custom domain on go daddy blogger widgets
PDF
Outline for action research prospectus
PDF
You have decided to go off on your own as a freelance webdesigner
PDF
Making a basicappinflash (1)
PDF
Daniel Downs Technology Portfolio Final May 2013 final (1)
PDF
Web design 1& 2 lesson outline
PDF
You are part of an international news team reporting from a foreign country
PDF
Marketing plan powerpoint
PDF
Final screen castfinalweb12
PDF
Info processing photoshop projects
Ipad quick-reference-2
Index of jquery template 2 Minuteman Summer Web Dev.
Jquery template 1 3 pages
Module6 htmlcss helpfulcodeandwebsites
Module 4 Minuteman Lexington Web Design Daniel Downs
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
Module 2 lexington minuteman web development basic layout template
Module 1 Web design & Development Lexington Minuteman
App research project
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
Blogger custom domain on go daddy blogger widgets
Outline for action research prospectus
You have decided to go off on your own as a freelance webdesigner
Making a basicappinflash (1)
Daniel Downs Technology Portfolio Final May 2013 final (1)
Web design 1& 2 lesson outline
You are part of an international news team reporting from a foreign country
Marketing plan powerpoint
Final screen castfinalweb12
Info processing photoshop projects

Recently uploaded (20)

PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Approach and Philosophy of On baking technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
KodekX | Application Modernization Development
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Big Data Technologies - Introduction.pptx
PPT
Teaching material agriculture food technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25 Week I
Approach and Philosophy of On baking technology
20250228 LYD VKU AI Blended-Learning.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Review of recent advances in non-invasive hemoglobin estimation
KodekX | Application Modernization Development
Digital-Transformation-Roadmap-for-Companies.pptx
sap open course for s4hana steps from ECC to s4
MIND Revenue Release Quarter 2 2025 Press Release
Big Data Technologies - Introduction.pptx
Teaching material agriculture food technology
Chapter 3 Spatial Domain Image Processing.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Programs and apps: productivity, graphics, security and other tools
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Understanding_Digital_Forensics_Presentation.pptx

Css web gallery

  • 1. Search ASP CSS DHTML HTML JavaScript Perl PHP RSS XHTML XML 3D Modeling Design Design Lab Graphics HTML Tools Internet JavaScript Tools Multimedia Programming Promotion Reviews Search Engine Resources Video Web Servers Color Codes HTML Characters HTML Tags JavaScript Core Reference Section Site Services XML [previous] [next] Web Developer/Designer Targus US-CA-Anaheim Post A Job | Post A Resume tip archive • about • sitemap • contact • jobs • write for us • subscribe home | programming | css_gallery | How to Create a Photographic Gallery Using CSS / Page 2 How to Create a Photographic Gallery Using CSS [con't] My images are either 372px high by 240px wide (portrait format) or 240px high by 372px wide (landscape format). These sizes have been calculated for several reasons, namely: To enable the gallery to fit within a screen resolution of 800 x 600 pixels without the need for scrolling. 1. To give thumbnail images of 93px by 60px (a quarter of the full size), which I consider to be large enough to give a good preview of the full size image. 2. To enable me to place three portrait thumbnails OR two landscape thumbnails in a line using a border of 1 pixel and a left / right margin of 2 pixels. 3. A horizontal row of three portrait images, 60px wide, each one having a border of 1px and a left / right margin of 2px gives a total width of 3 times 66px which is 198px. A horizontal row of two landscape images, 93px wide, each one having a border of 1px and a left / right margin of 2px gives a total width of 2 times 99px which is also 198px. I find it best to sketch out a rough plan of the gallery before I begin to add the styling, this way I can calculate the best size for my thumbnails and full size images. A little bit of thought 'up front' will save a lot of frustration and redesign. MARKETPLACE Get Your Six Sigma Certification Earn Villanova Six Sigma Certification 100% Online Program -- FREE Info. VillanovaU.com/SixSigma With Less, Do More Windows 7 Professional and the Windows Server 2008 Family Microsoft.com/SmallBusiness Internet Marketing Master's Degree Learn Effective Internet Marketing Strategies While Earning Your Masters Online! www.FullSail.edu IT Professionals Developers Solutions eBook Library Webopedia Login Register Page 1 of 6How to Create a Photographic Gallery Using CSS / Page 2 8/17/2010http://www.webreference.com/programming/css_gallery/2.html
  • 2. Newletters Networking Daily submit Eclipse Helios Update Brings New PHP Tools Internet Explorer 9 Ups Standards Support JBoss Portal 5 Release Easier to Use Step 2 The !DOCTYPE Firstly and most importantly, make sure that you have the correct (X)HTML !DOCTYPE. Without this most browsers will be thrown into 'quirks' mode which will lead to all sorts of incompatibility problems. W3C QA - List of valid DTDs has a list of valid DOCTYPES that can be used. Select from XHTML1.0 or XHTML1.1 as these are more suitable for this styling. I use XHTML1.1 for all my current web pages. Step 3 Adding links and style information In order that I can use the :hover pseudo class style I need to change the basic unordered list into an unordered list of links. This is because Internet Explorer will only allow :hover to be used on links. I also need to add extra markup to target specific images. The (x)html will now look like this: 1 <div id="container"> 2 <ul> 3 <li> 4 <a class="gallery slidea" href="#nogo"> 5 <span> 6 <img src="../images/p1.jpg" alt="Alpha" title="Alpha" /> 7 <br /> 8 ALPHA 9 <br /> 10 Photographed by Dorota Mrowka, courtesy of the stock.xchng 11 </span> 12 </a> 13 </li> 14 <li> 15 <a class="gallery slideb" href="#nogo"> 16 <span> 17 <img src="../images/p2.jpg" alt="Minie" title="Minie" /> 18 <br /> 19 MINIE 20 <br /> 21 Photographed by José Antonio Assis, courtesy of the stock.xchng 22 </span> 23 </a> 24 </li> 25 <li> 26 <a class="gallery slidec" href="#nogo"> 27 <span> 28 <img src="../images/p3.jpg" alt="Megan" title="Megan" /> 29 <br /> 30 MEGAN 31 <br /> 32 Photographed by Rob Waterhouse, courtesy of the stock.xchng 33 </span> 34 </a> 35 </li> 36 <li> 37 <a class="gallery slided" href="#nogo"> 38 <span> 39 <img src="../images/p4.jpg" alt="Nancy" title="Nancy" /> 40 <br /> 41 NANCY 42 <br /> 43 Photographed by Philip Keller, courtesy of the stock.xchng 44 </span> 45 </a> view plain | print | copy to clipboard | ? Page 2 of 6How to Create a Photographic Gallery Using CSS / Page 2 8/17/2010http://www.webreference.com/programming/css_gallery/2.html
  • 3. 46 </li> 47 <li> 48 <a class="gallery slidee" href="#nogo"> 49 <span><img src="../images/p5.jpg" alt="Missy" title="Missy" /> 50 <br /> 51 MISSY & PANDA 52 <br /> 53 Photographed by Kat Shurtz, courtesy of the stock.xchng 54 </span> 55 </a> 56 </li> 57 <li> 58 <a class="gallery slidef" href="#nogo"> 59 <span> 60 <img src="../images/p6.jpg" alt="Stray pup" title="Stray pup" /> 61 <br /> 62 STRAY PUP 63 <br /> 64 Photographed by Bethan Hazell, courtesy of the stock.xchng 65 </span> 66 </a> 67 </li> 68 <li> 69 <a class="gallery slideg" href="#nogo"> 70 <span> 71 <img src="../images/p7.jpg" alt="Rolo" title="Rolo" /> 72 <br /> 73 ROLO 74 <br /> 75 Photographed by Paul Leach, courtesy of the stock.xchng 76 </span> 77 </a> 78 </li> 79 <li> 80 <a class="gallery slideh" href="#nogo"> 81 <span> 82 <img src="../images/p8.jpg" alt="Gigio" title="Gigio" /> 83 <br /> 84 GIGIO 85 <br /> 86 Photographed by Davide Guglielmo, courtesy of the stock.xchng 87 </span> 88 </a> 89 </li> 90 <li> 91 <a class="gallery slidei" href="#nogo"> 92 <span> 93 <img src="../images/p9.jpg" alt="Westy pup" title="Westy Pup" /> 94 <br /> 95 WESTY PUP 96 <br /> 97 Photographed by Rob Waterhouse, courtesy of the stock.xchng 98 </span> 99 </a> 100 </li> 101 <li> 102 <a class="gallery slidej" href="#nogo"> 103 <span> 104 <img src="../images/p10.jpg" alt="Giga Byte" title="Fishing" /> 105 <br /> 106 GIGA BYTE 107 <br /> 108 Photographed by Jefras, courtesy of the stock.xchng 109 </span> 110 </a> 111 </li> 112 <li> 113 <a class="gallery slidek" href="#nogo"> view plain | print | copy to clipboard | ? Page 3 of 6How to Create a Photographic Gallery Using CSS / Page 2 8/17/2010http://www.webreference.com/programming/css_gallery/2.html
  • 4. 114 <span> 115 <img src="../images/p11.jpg" alt="Puppy" title="Puppy" /> 116 <br /> 117 PUPPY 118 <br /> 119 Photographed by Clodiney Cruz, courtesy of the stock.xchng 120 </span> 121 </a> 122 </li> 123 <li> 124 <a class="gallery slidel" href="#nogo"> 125 <span> 126 <img src="../images/p12.jpg" alt="Buffy" title="Buffy" /> 127 <br /> 128 BUFFY 129 <br /> 130 Photographed by Rob Waterhouse, courtesy of the stock.xchng 131 </span> 132 </a> 133 </li> 134 </ul> 135 </div> view plain | print | copy to clipboard | ? ‡ Style Ready List Every list item is now enclosed in a link which has a common gallery class and a unique slide letter class. They are also further enclosed by a span which does not have any specific class or id. I have used href="#nogo" instead of the more usual href="#" so that anyone clicking the link will not jump to the top of the page (just make sure you do not have an anchor #nogo on your page). You can, if you wish use this to link to take visitors to a larger image on a new page. The (x)html unordered list is now complete and I will not need to make any more changes to it. The Styling Step 4 The body The <body> is first to be styled with the font-family for the whole page. I have chosen Tahoma as the first choice but you can select any font you wish. I have also chosen a font size of 76% as this is gives a suitable default size for most screen resolutions. It also allows Internet Explorer users to resize the font if they wish. 1 /* choose a suitable font and center the #container div in Internet Explorer */ 2 body { 3 text-align:center; 4 font-family: tahoma; arial, sans-serif; 5 font-size:76%; 6 letter-spacing:0.05em; 7 } view plain | print | copy to clipboard | ? I have added text-align:center; so that Internet Explorer will place the #container div centrally (left / right) on the page. This will only target Internet Explorer and Opera, all other browsers will ignore this styling. I will use the 'correct method' as described in Step 4 to target all other browsers. Page 4 of 6How to Create a Photographic Gallery Using CSS / Page 2 8/17/2010http://www.webreference.com/programming/css_gallery/2.html
  • 5. [previous] [next] ‡ Example #1 Step 5 The container In order that the gallery can be viewed at a resolution of 800 x 600 I will limit the #container div to a fixed size of 770px wide by 396px high. I will also add a 1px thick grey border. This is fairly straightforward to style as seen below: 1 /* The containing box for the gallery. */ 2 #container { 3 position:relative; 4 width:770px; 5 height:396px; 6 margin:20px auto 0 auto; 7 border:1px solid #aaa; 8 } view plain | print | copy to clipboard | ? ‡ Example #2 I have given this div a relative position so that I can position the gallery images within it using absolute positions. The margins have been given a left / right value of auto so that all browsers, except Internet Explorer (which has been taken care of in Step 3 above), will center the div (left / right) on the page. Depending on which browser you are using you will see either the images overflowing the container or the images held within an expanded container. The 'correct' interpretation is that the images should overflow the container. Step 6 Removing the bullets I will need to style the unordered list by removing the bullets and the indentation. Browsers have different ways of doing this, Internet Explorer and Opera use margin values for the indentation whereas Mozilla/Netscape/Firefox all use padding values, so to cater for this I need to style the list as follows. 1 /* Removing the list bullets and indentation */ 2 #container ul { 3 padding:0; 4 margin:0; 5 list-style-type:none; 6 } view plain | print | copy to clipboard | ? ‡ Example #3 Now the bullets are gone. home | programming | css_gallery | How to Create a Photographic Gallery Using CSS / Page 2 Page 5 of 6How to Create a Photographic Gallery Using CSS / Page 2 8/17/2010http://www.webreference.com/programming/css_gallery/2.html
  • 6. Add Multilingual Support to Your Java Web Pages Creating an ASP.NET Registration and Confirmation System Build Your Own PHP Web Mailer MySQL in Amazon EC2 - Beginners Guide Spiceworks 5.0 Beta Adds New Help Desk Features 7 Ways to Help Customers Trust Your Ecommerce Website The Network for Technology Professionals Search: About Internet.com Copyright 2010 QuinStreet Inc. All Rights Reserved. Legal Notices, Licensing, Permissions, Privacy Policy. Advertise | Newsletters | E-mail Offers Solutions Whitepapers and eBooks Helpful Cloud Computing Resources MORE WHITEPAPERS, EBOOKS, AND ARTICLES Webcasts User Experience Management Indicators for Business and IT Success Ensuring Performance Meets Business and Web User Needs MORE WEBCASTS, PODCASTS, AND VIDEOS Downloads and eKits Get BlackBerry Enterprise Server Express for Free MORE DOWNLOADS, EKITS, AND FREE TRIALS Tutorials and Demos Demo: Google Site Search Virtual Event: Master Essential Techniques for Leveraging the Cloud Article: Explore Application Lifecycle Management Tools in Visual Studio 2010 Internet.com Hot List: Get the Inside Scoop on IT and Developer Products New Security Solutions Using Intel(R) vPro(TM) Technology All About Botnets MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES Page 6 of 6How to Create a Photographic Gallery Using CSS / Page 2 8/17/2010http://www.webreference.com/programming/css_gallery/2.html