Quote from: overhaulmedia at Jan 31, 2009, 08:05 PM
would you mid sharing the css you use?
Thanks!
Well, I can’t "officially" share it, because the site belongs to my employer, not me. However, I’m very much in favour of learning from other people’s code, so, for anyone who is interested in how it works, here is the code.
Here is the generic CSS for the gallery:
/*mozilla outline - doesn't validate, used to prettify mini gallery in mozilla browsers*/
#gallery a:focus, #gallery a:active {
-moz-outline: none;
}
#gallerybox {
float: right;
padding: 10px 0 0 20px;
background: #fff;
}
/*container with default background image*/
#gallery {
position: relative;
width: 368px;
height: 314px;
background-color: #404040;
}
#gallery ul {
position:absolute;
left: 4px; bottom: 0px;
list-style: none;
margin: 0;
}
/*hide name of gallery*/
#gallery h2 {
display: none;
position: absolute;
left: -9000px; top: -9000px;
}
#gallery #start {
background: url(../graphics/gallery_start.png) 0 0 no-repeat;
height: 5px;
width: 5px;
position: absolute;
top: 0; left: 0;
z-index: 200;
}
#gallery #end {
background: url(../graphics/gallery_end.gif) 0 100% no-repeat;
height: 5px;
width: 5px;
position: absolute;
bottom: 0; left: 0;
}
#gallery li {
display: inline;
margin: 0;
}
/* thumbnail links */
#gallery a {
display: block;
width: 52px;
height: 58px;
float: left;
padding: 2px 4px;
border: 0;
}
/*ff*/
#gallery a span.thumb {
display: block;
width: 50px;
height: 50px;
overflow: hidden;
border: 1px solid #222;
}
#gallery img {
max-width: 380px;
border: 0;
}
/*turn off fullsize images*/
#gallery a span.full {
display: none;
}
/*thumbnail behaviour*/
#gallery a:hover .thumb {
border: 1px solid #fff;
}
#gallery a:active .thumb, #gallery a:focus .thumb {
border: 1px solid #CF01B1;
}
/*full-size behaviour*/
#gallery a:hover span.full, #gallery a:active span.full, #gallery a:focus span.full {
display: block;
position: absolute;
width: 368px;
height: 246px;
top: -252px;
left: -4px;
z-index: 2;
}
#gallery a:hover span.full {
z-index: 2;
}
#gallery a:active span.full, #gallery a:focus span.full {
z-index: 1;
}
/*gallery navigation*/
#gallerynav {
text-align: right;
margin: .5em 10px 0 0;
font-size: 79%;
line-height: 1.5em;
}
#gallerynav.nav li {
margin: 0;
border-left: 1px solid #999;
}
#gallerynav.nav li.first {
border: 0;
}
#gallerynav.nav a {
margin: 0 6px 0 6px;
text-decoration: none;
border: 0;
}
#gallerynav.nav a:hover {
text-decoration: underline;
}
Here are the inevitable fixes for Internet Explorer.
IE7 or lower:
/*
mini gallery fixes
---------------------------------------------------------------------------------*/
#gallery ul {
bottom: 8px;
}
#gallery a span.thumb {
display: inline;
border: 0;
}
#gallery a:hover .thumb, #gallery a:active .thumb, #gallery a:focus .thumb {
border: 0;
}
/*turn off block span used in FF and move borders to link*/
body #gallery a {
display: inline-block;
overflow: hidden;
width: 50px;
height: 50px;
padding: 0;
margin: 2px 4px 0 4px;
border: 1px solid #222;
}
#gallery a:hover {
border: 1px solid #fff;
}
#gallery a:active, #gallery a:focus {
border: 1px solid #f93;
}
IE6 or lower:
/*
transparent png background in IE6/IE5.5 for mini gallery
---------------------------------------------------------------------------------*/
#gallery #start {
/* MS image filter */
background: none;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='graphics/gallery_start.png', sizingMethod='crop');
}
IE5:
/*
trigger hasLayout including easy clear
---------------------------------------------------------------------------------*/
#gallerynav a, #gallerynav li {
height: 1px;
}
/*
mini gallery fixes
---------------------------------------------------------------------------------*/
/*turn off thumbnails*/
#gallery ul, #gallery #end {
display: none;
}
#gallery {
height: 246px;
}
Then you need the following for each individual gallery:
/* positioned and scaled thumbnail images. Adjust these values to 'focus' the thumbnails. */
.gallery-about .img1 img {height: 61px; margin: 0 0 0 -5px;}
.gallery-about .img2 img {height: 90px; margin: -15px 0 0 -10px;}
.gallery-about .img3 img {height: 110px; margin: -30px 0 0 -70px;}
.gallery-about .img4 img {height: 123px; margin: -10px 0 0 0px;}
.gallery-about .img5 img {height: 130px; margin: -12px 0 0 -87px;}
.gallery-about .img6 img {height: 90px; margin: -5px 0 0 -61px;}
/*default image*/
.gallery-about {
background: url(../graphics/gallery/about/img1.jpg) 0 0 no-repeat;
}
/*full-size backgrounds*/
.gallery-about .img1 span.full {background: url(../graphics/gallery/about/img1.jpg)}
.gallery-about .img2 span.full {background: url(../graphics/gallery/about/img2.jpg);}
.gallery-about .img3 span.full {background: url(../graphics/gallery/about/img3.jpg);}
.gallery-about .img4 span.full {background: url(../graphics/gallery/about/img4.jpg);}
.gallery-about .img5 span.full {background: url(../graphics/gallery/about/img5.jpg);}
.gallery-about .img6 span.full {background: url(../graphics/gallery/about/img6.jpg);}
And, finally, the HTML to tie it all together, again needed for each gallery.
<div id="gallerybox">
<div id="gallery" class="gallery-about"><div id="start"></div>
<h2>Image Gallery</h2>
<ul>
<li><a class="img1" href="/"><span class="thumb"><img src="graphics/gallery/about/img1.jpg" alt="" title="" /></span><span class="full" title=""></span></a></li>
<li><a class="img2" href="/"><span class="thumb"><img src="graphics/gallery/about/img2.jpg" alt="" title="" /></span><span class="full" title=""></span></a></li>
<li><a class="img3" href="/"><span class="thumb"><img src="graphics/gallery/about/img3.jpg" alt="" title="" /></span><span class="full" title=""></span></a></li>
<li><a class="img4" href="/"><span class="thumb"><img src="graphics/gallery/about/img4.jpg" alt="" title="" /></span><span class="full" title=""></span></a></li>
<li><a class="img5" href="/"><span class="thumb"><img src="graphics/gallery/about/img5.jpg" alt="" title="" /></span><span class="full" title=""></span></a></li>
<li><a class="img6" href="/"><span class="thumb"><img src="graphics/gallery/about/img6.jpg" alt="" title="" /></span><span class="full" title=""></span></a></li>
</ul>
<div id="end"></div>
</div>
I put the CSS in external files and use chunks for the HTML, but I’m sure there are loads of other ways of doing it.
And, yeah, it is a bit complicated!
Furthermore, each thumbnail is a link. In a static site, this is fine, but because of something MODx does, if you click on the thumbnails, the page reloads. (What is supposed to happen is that if you click on a thumbnail, it makes that image ’sticky’.) I’ve put in a couple of javascript files to intercept the click, which I’m also happy to share. There may be a better way to do this within MODx.
By the way, I don’t claim credit for this CSS. I only did the MODx integration. The design and coding were by Mark Hadley:
http://markhadley.com/.