<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ashita.org &#187; filmstrip</title>
	<atom:link href="http://www.ashita.org/tag/filmstrip/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ashita.org</link>
	<description></description>
	<lastBuildDate>Wed, 27 Apr 2011 22:37:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>CSS filmstrip</title>
		<link>http://www.ashita.org/css-and-javascript-filmstrip/</link>
		<comments>http://www.ashita.org/css-and-javascript-filmstrip/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 03:34:36 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[filmstrip]]></category>
		<category><![CDATA[img]]></category>
		<category><![CDATA[pictures]]></category>

		<guid isPermaLink="false">http://ashita.org/?p=99</guid>
		<description><![CDATA[Previously, we looked at using CSS opacity to create some interesting effects. In this aricle we&#8217;ll be using the CSS opacity technique to create some interesting effects in a filmstrip. To start with, let&#8217;s work from the assumption that all of our thumbnails are the same size and shape. For this example, thumbnails will be [...]]]></description>
			<content:encoded><![CDATA[<p>Previously, we looked at using CSS opacity to create some interesting effects. In this aricle we&#8217;ll be using the CSS opacity technique to create some interesting effects in a filmstrip.</p>
<p>To start with, let&#8217;s work from the assumption that all of our thumbnails are the same size and shape. For this example, thumbnails will be 140&#215;100. This is of course, the kind of thing you could change in user preferences for a web app, but let&#8217;s start simple. So using a short strip of 3 pictures, we have some XHTML that looks like this.</p>
<pre>&lt;img src="/images/mythumb01.jpg"/&gt;&lt;img src="/images/mythumb02.jpg"/&gt;&lt;img src="/images/mythumb03.jpg"/&gt;</pre>
<p>But the first problem we see, of course, is that they are oriented vertically&#8230;. which is fine, but let&#8217;s try for a horizontal strip, shall we. In the bad old days we&#8217;d have done this in a table. I&#8217;m talking Netscape 4 days, here *shudder*. Moving quickly on, a good tip for whenever you want strict rows or columns of something is to use an unordered list and some CSS, like this:</p>
<pre>
&lt;ul class="imageRow"&gt;
	&lt;li&gt;&lt;img src="/images/mythumb01.jpg"/&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src="/images/mythumb02.jpg"/&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src="/images/mythumb03.jpg"/&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<pre>ul.imageRow {
	width: 450px; /*width of all of your images plus the margins/padding you use*/
	height:140px;
}

ul.imageRow li {
	float: left;
	display: block;
	padding: 7px;
	margin: 0px;
}

ul.imageRow li img {
	border: 0px;
	height: 100px; /* just incase the images are a different size */
	width: 140px; /* ditto */
	margin: 0px;
	padding:0px;
}</pre>
<p>This will give us something like this:</p>
<ul style="list-style-image: none; list-style-type: none; height: 100px; width: 450px;">
<li style="background: none; float: left; display: block; padding: 0px; margin: 0px 0px 0px 10px;"><img src="/images/mythumb01.jpg" style="height:100px; width:140px;margin:0px; padding: 0px;" alt="" /></li>
<li style="background: none; float: left; display: block; padding: 0px; margin: 0px 0px 0px 10px;"><img src="/images/mythumb02.jpg" style="height:100px; width:140px;margin:0px; padding: 0px;" alt="" /></li>
<li style="background: none; float: left; display: block; padding: 0px; margin: 0px 0px 0px 10px;"><img src="/images/mythumb03.jpg" style="height:100px; width:140px;margin:0px; padding: 0px;" alt="" /></li>
</ul>
<p>What if you want to show a lot of images and, say, have the box scroll horizontally? The solution is to add a <code>&lt;div&gt;</code> with a width smaller than the <code>&lt;ul&gt;</code>.</p>
<pre>div.filmstrip {
	overflow-x: scroll;
	overflow-y: hidden;
	height: 140px; /* give it enough space for the images and the scrollbar, if present */
}</pre>
<pre>&lt;div class="filmstrip"&gt;
	&lt;ul class="imageRow"&gt;
	.
	.
	.
	&lt;/ul&gt;
&lt;/div&gt;</pre>
<p>Which gives us the following:</p>
<div style="overflow-y:hidden; overflow-x: scroll; height:140px;">
<ul style="list-style-image: none; list-style-type: none; height: 100px; width: 900px;">
<li style="background: none; float: left; display: block; padding: 0px; margin: 0px 0px 0px 10px;"><img src="/images/mythumb01.jpg" style="height:100px; width:140px;margin:0px; padding: 0px;" alt="" /></li>
<li style="background: none; float: left; display: block; padding: 0px; margin: 0px 0px 0px 10px;"><img src="/images/mythumb02.jpg" style="height:100px; width:140px;margin:0px; padding: 0px;" alt="" /></li>
<li style="background: none; float: left; display: block; padding: 0px; margin: 0px 0px 0px 10px;"><img src="/images/mythumb03.jpg" style="height:100px; width:140px;margin:0px; padding: 0px;" alt="" /></li>
<li style="background: none; float: left; display: block; padding: 0px; margin: 0px 0px 0px 10px;"><img src="/images/mythumb04.jpg" style="height:100px; width:140px;margin:0px; padding: 0px;" alt="" /></li>
<li style="background: none; float: left; display: block; padding: 0px; margin: 0px 0px 0px 10px;"><img src="/images/mythumb05.jpg" style="height:100px; width:140px;margin:0px; padding: 0px;" alt="" /></li>
<li style="background: none; float: left; display: block; padding: 0px; margin: 0px 0px 0px 10px;"><img src="/images/mythumb06.jpg" style="height:100px; width:140px;margin:0px; padding: 0px;" alt="" /></li>
</ul>
</div>
<p>Now I promised using opacity as a way to highlight pictures, so here it is:</p>
<pre>
ul.imageRow li {
	float: left;
	display: block;
	padding: 7px;
	margin: 0px;
	opacity: 0.7;
	filter: alpha(opacity=70);
}
ul.imageRow li:hover {
	opacity: 1.0;
	filter: alpha(opacity=100);
}</pre>
<p>This gives us:</p>
<div class="filmstripTut">
<ul class="imageRow">
<li class="opac"><img src="/images/mythumb01.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb02.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb03.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb04.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb05.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb06.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb01.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb02.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb03.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb04.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb05.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb06.jpg" alt="" /></li>
</ul>
</div>
<p>Here are some other ways to add a highlight to the active picture:</p>
<pre>
ul.imageRow li {
	float: left;
	display: block;
	padding: 7px;
	margin: 0px;
	background-color: #fff;
}
ul.imageRow li:hover {
	background-color:#bef;
}</pre>
<div class="filmstripTut">
<ul class="imageRow">
<li class="bg"><img src="/images/mythumb01.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb02.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb03.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb04.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb05.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb06.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb01.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb02.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb03.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb04.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb05.jpg" alt="" /></li>
<li class="bg"><img src="/images/mythumb06.jpg" alt="" /></li>
</ul>
</div>
<pre>
ul.imageRow li {
	float: left;
	display: block;
	padding: 7px;
	margin: 0px;
}
ul.imageRow li:hover {
	padding: 4px;  /* IMPORTANT: allows the 3px border to fill the gap so the element
				is the same size as before */
	border: 3px dashed red;
}</pre>
<div class="filmstripTut">
<ul class="imageRow">
<li class="border"><img src="/images/mythumb01.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb02.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb03.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb04.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb05.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb06.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb01.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb02.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb03.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb04.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb05.jpg" alt="" /></li>
<li class="border"><img src="/images/mythumb06.jpg" alt="" /></li>
</ul>
</div>
<p>Going back to the opacity example, let&#8217;s change the background and add an image to give it that filmstrip feel.</p>
<pre>
div.filmstrip {
	overflow-x: scroll;
	overflow-y: hidden;
	height: 180px; /* give it enough space for the images and the scrollbar, if present (and the
				 filmstrip image) */
	padding: 0px;
	background-color: #000;
}

ul.imageRow {
	width: 1848px; /*width of all of your images plus the margins/padding you use*/
	height: 170px;
	background: url(/images/filmstrip.jpg) 0 0 repeat-x;
	padding: 25px 0px 25px 0px;
	margin: 0px;
}</pre>
<div class="filmstrip">
<ul class="imageRow">
<li class="opac"><img src="/images/mythumb01.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb02.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb03.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb04.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb05.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb06.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb01.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb02.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb03.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb04.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb05.jpg" alt="" /></li>
<li class="opac"><img src="/images/mythumb06.jpg" alt="" /></li>
</ul>
</div>
<p>We could have added the filmstrip background to the div instead of the list, but then the strip doesn&#8217;t appear to scroll. Sometimes that&#8217;s desirable, here it isn&#8217;t. Other things to note are that we&#8217;ve added padding to the top and bottom of the unordered list so the thumbnails now fit within the intended area.</p>
<p>Okay, but what about those ugly scroll bars? Well, In the next article we&#8217;ll look at some alternatives using Javascript and CSS positioning.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ashita.org/css-and-javascript-filmstrip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

