If you like to have a simple photo album on your blog, here is an easy to implement solution, without any javascript! It is just CSS, and a bunch of html-links to the pictures you want to display. I found this toy at Stu Nichols's CSSPlay, and wanted to share it with you.
Attention: if you add this to your Blog using the Blogger editor (as I did), Blogger adds <br/>-tags where it sees new lines. These <br/>-tags mess up the album when displayed with Firefox.
First, you have to add the following CSS to your style-sheet.
/* Photo album */
#album {
width:320px;
height:360px;
background:#eee url(deer.jpg) 0 40px no-repeat;
border:1px solid #aaa;
margin:0 auto;
text-align:center;
}
.gallery {
position: relative;
margin: 320px 0 0 0;
width: 320px;
padding: 0;
list-style-type: none;
}
.gallery img {
border: 0;
}
.gallery li {
float: left;
}
.gallery li a, .gallery li a:visited {
font-size:11px;
float:left;
text-decoration:none;
color:#000;
background:#fff;
text-align:center;
width:26px;
height:26px;
line-height:24px;
border:1px solid #444;
margin:2px;
}
.gallery li a img {
position:absolute;
top:-320px;
left:0;
visibility:hidden;
border:0;
padding:0;
}
.gallery li a img.landscape {
top:-280px;
}
.gallery li a img.portrait {
left:0;
border-left:40px solid #eee;
border-right:40px solid #eee;
}
.gallery li a:hover {
background:#ddd;
}
.gallery li a:active img, .gallery li a:focus img {
visibility:visible;
}
.gallery li a:active, .gallery li a:focus {
background:#444;
color:#fff;
}
*/ End photo album */
Second, find the a:link definition in your CSS, and add definitions for a:visited, a:hover and a:active. you can format these anyway you like, but they must be in your template for the photo-album to work correctly (because of a bug in IE).
Third, at the spot where you want the album to appear, add the following html:
<div id="album">
<ul class="gallery">
<li><a href="#nogo">01<img class="landscape" src="image1.jpg" alt="image 1" title="image 1" />&;t;/a></li>
<li><a href="#nogo">02<img class="portrait" src="image2.jpg" alt="image 2" title="image 2" />&;t;/a></li>
<li><a href="#nogo">03<img class="portrait" src="image3.jpg" alt="image 3" title="image 3" />&;t;/a></li>
<li><a href="#nogo">04<img class="landscape" src="image4.jpg" alt="image 4" title="image 4" />&;t;/a></li>
<li><a href="#nogo">05<img class="portrait" src="image5.jpg" alt="image 5" title="image 5" />&;t;/a></li>
<li><a href="#nogo">06<img class="portrait" src="image6.jpg" alt="image 6" title="image 6" />&;t;/a></li>
<li><a href="#nogo">07<img class="landscape" src="image7.jpg" alt="image 7" title="image 7" />&;t;/a></li>
<li><a href="#nogo">08<img class="landscape" src="image8.jpg" alt="image 8" title="image 8" />&;t;/a></li>
<li><a href="#nogo">09<img class="portrait" src="image9.jpg" alt="image 9" title="image 9" />&;t;/a></li>
<li><a href="#nogo">10<img class="landscape" src="image10.jpg" alt="image 10" title="image 10" />&;t;/a></li>
</ul>
</div>
Each img src has to point to a picture. The class of this picture can be portrait or landscape.
4 New Gadgets from Blogger Buster
4 days ago











This is what people say:
It's a nice touch, Hans. However were you aware that it doesn't render properly in Firefox (1.5.0.7)? The number links sprawl diagonally down the page and obscure the 'Read More' link on the front page making it inaccessible.
The same problem occurs in Opera, Hans. Looks and works great in IE, though.
Martin, thanks for pointing it out! I checked its source at Stu Nicholson, and there it displays okay in Firefox. I guess that because it is inside a post now some of the settings of the other divs and classes affect the photo album.
I am looking into it and will correct it asap.
Good show
Martin, the FF-problem is solved now.
Can't seem to get it well :( on both IE and Firefox
it's a pity that BloggerBeta Blocked in china again ! i hate the GOV!
@esc: most probable cause it that the CSS of other part of your Blog interferes with the CSS of the photo-album. Leave a link here and I will take a look at it.
So I see, Hans. I love the simplicity of this and how it works so well. Great blog with choice hacks, bye the way. I'm coming back to blogging after a couple of years away; I'll definitely be making use of your ideas.
Until now i was able to incorporate several hacks of yours (kezdoszolesz.blogspot). Thanks for that! However i struggle with your photo album on my test blog. I copied exactly as you described but by clicking on the image labels the images pop up over the spot somehow. Can't go further. Is there a way to fix it? tks in advance.
Hi Hans,
Here is the link esc2test.blogspot.com
I tested on both IE6 and Firefox, both are not working correctly.
Really appreciate you help.
Many Thanks.
@esc: there are two problems in your template that mess up the photo album. First, you have a .post ul definition and a .post li definition that set a padding. This .post padding overrides the .gallery padding. Because your gallery is inside a post, it takes its formatting from the post, unless it is changed for the gallery (thats why CSS is called Cascading). So the order of definitions has to be: post first, gallery later. Just for testing: remove the padding from the .post ul and the .post li and the buttons will be okay.
Now the second problem: when you click a button, the picture doesn't pop up instantly as it should; it pops up if you move the mouse away from the button. Your template is missing definitions for a:link, a: visited, a:hover and a:active at the beginning of the style sheet.
@spicc: from your template, remove the line "margin:0;" from the .post ul definition. And add a path to the albums background url.
Looks great! I use firefox. You have some great ideas.
Thanks Janet!
I'm having a little trouble with steps 2 and 3 (I'm a very new blogger and don't have any experience with code)... will this work in Blogger Beta?
I'm getting an error message on step 3 when I try to place it in a post. Then again, I'm probably messing up step 2...
@Brian: to be honest: if you are new to coding the simple Photo Album is not the best thing to start with. It took me a considerable amount of time to get it up and running. Simple means: not much functionality. Simple does not mean: easy to add. Problems might arise with the template styling. The styling definitions of other html-elements might conflict with those of the photo album, and it may take lots of time to solve the problem. If you are new to coding, I suggest that you use for example Flickr, upload some pictures to it, create a Flickr Badge, and add that to your sidebar (that means copying a few lines of code and paste it into a sidebar page element).
I have created my own album based on the code you've shown here, as a more interactive tour feature. Three thumbnails (the numbered li elements have been changed to divs) link to 640x480 background pics that you should be able to peruse between. However, the thumbnails overlap the area on which the full resolution photos appear, and when the photos appear they cover the original thumbnails. I have tried all manners of z-index, but nothing has worked. Do you know of any way, besides layering, to get the full-rez photos to appear below the thumbnails? If not, could I be layering the wrong classes? If my explanation is not sufficient, I have posted the code at:
http://www.uniquelyitaly.110mb.com/preview/test.txt
There are no images as of yet (because, again, it doesn't work) but I hope you can get the idea of what I am trying to accomplish.
Oh, and for now, I have deliberately left the file in .txt format so that it won't render in most browsers if someone stumbles upon it. I will convert it back to HTML later.
Hello Hans,
I tried this photo gallery tutorial and it worked out beautifully. The only thing is: I need the buttons to be in a vertical line, instead of a horizontal one...
I don't know almost anything about css. What do I have to change in the code to make it a vertical list, instead of horizontal?
Thanks for your great tutorials!
Alice
@Seth and Alice: I am not a real CSS guru. I got the Photo Album from Stu Nichols's excellent CSS tutorials. And he helped me out with some problems I had integrating this photoalbum into Blogger. I suggest you take a look there and ask his advice.
I managed to prevent the images from rendering on top of thumbnails by placing the thumbnails elsewhere on the page. Alice, you can use absolute positionging with the thumbnail divs within the #album div. Google: CSS Positioning tutorials for more info. Also, post a link to the site you're working on (if it's online) and maybe someone will be able to look at it in more detail.
hi hanz,
how about putting a caption on every pictures? can we do it?
Share your thoughts!
Feel free to post your questions, remarks and comments here. Moderation is set for this blog, so your comments will appear in due time.
Look who's linking here!
0 Backlinks point here