888888.888888.88""Yb..dP"Yb..8888b..Yb..dP.88b.88....db....8b....d8.88..dP""b8..dP"Y8
88__...88__...88__dP.dP...Yb..8I..Yb.YbdP..88Yb88...dPYb...88b..d88.88.dP...`".`Ybo."
88""...88""...88"Yb..Yb...dP..8I..dY..8P...88.Y88..dP__Yb..88YbdP88.88.Yb......o.`Y8b
88.....888888.88..Yb..YbodP..8888Y"..dP....88..Y8.dP""""Yb.88.YY.88.88..YboodP.8bodP'


88b.88.888888.888888.Yb........dP.dP"Yb..88""Yb.88..dP
88Yb88.88__.....88....Yb..db..dP.dP...Yb.88__dP.88odP.
88.Y88.88"".....88.....YbdPYbdP..Yb...dP.88"Yb..88"Yb.
88..Y8.888888...88......YP..YP....YbodP..88..Yb.88..Yb

February 27, 2010

Themery Blogged Title

This is the ninth post in my series, Themery : Blogged, where I blog about each step of a WordPress theme design.

This theme, as I explained in previous posts, is elastic, meaning that as you increase the text size, the rest of the site scales up accordingly. The problem with this is images, when images scale up on a webpage all kinds of evil ensues and so it can’t really be done. This is my solution.

I will start with some screenshots to demonstrate the end result, then explain what I have done. They aren’t small but I wanted to get across the scale of the problem.

This is the same page at the original font size, and several sizes larger. The bottom image is simply styled with a width in EMs, the image above uses my technique.

Image Screenshot 1 - Default font size
Image Screenshot 2 - 3 times size

Now, before I explain what I have done I wanted to temper expectations a little. This isn’t the grand solution to all image sizing, you might even consider it a slightly hacky solution to the problem, but it does work.

The short version is simply that the top image is actually 5 images, each at intermediate steps, 150px, 180px, 225px. 300px. and finally 450px. Using a div and absolute positioning each image comes into view as the appropriately sized text is selected.

The CSS is split between the stylesheet and inline styles. If you know what sizes your images will be before hand there is no reason why it can’t all be in the stylesheet.

The stylesheet contains two rules:

div.multiimage
{
overflow:hidden;
position:relative;
}

div.multiimage div.subimage
{
margin-top:-1000em;
position:absolute;
}

And the html looks like this:

<!– The Wrapper –>
<div style=”width:15em; height:10em;”>
<!– The original Image –>
<img src=”http://localhost:8080/wp-content/uploads/2008/03/11.jpg” alt=”Williams Formula 1 Car”  />
<!– Larger Image 1 –>
<div style=”width:18em; height:18em; top:12000px; background-image:url(http://localhost:8080/wp-content/uploads/2008/03/21.jpg);”></div>
<!– Larger Image 2 –>
<div style=”width:22.5em; height:22.5em; top:15000px; background-image:url(http://localhost:8080/wp-content/uploads/2008/03/31.jpg);”></div>
<!– Larger Image 3 –>
<div style=”width:30em; height:30em; top:20000px; background-image:url(http://localhost:8080/wp-content/uploads/2008/03/4.jpg);”></div>
<!– Larger Image 4 –>
<div style=”width:45em; height:45em; top:30000px; background-image:url(http://localhost:8080/wp-content/uploads/2008/03/5.jpg);”></div>
</div>

As the text is resized the negative margin (-1000em) of the larger images increases until it reaches a measure equal to the absolute position top, which is 1000 times the size that the base font (the font that applies to the body) will be when we want that image displayed, but in pixels so that it doesn’t change when the font is resized.

In this example the base font size, or 1em, is equal to 10px. So for the first larger image is positioned 12000 pixels from the top. When the font is increased to 1.2 the negative margin then equals 1000 times, i.e. -12000 and the image is displayed.

I have used div tags with backgrounds instead of images so that screenreaders do not end up listing image after image, this after all purely visual.

Disclaimer: As Safari won’t run on my computer I don’t know how it deals with resizing. Firefox on Windows resizes text as:1 , 1.2 , 1.5 , 2 , 3 and it is this I have based this on. Both Opera and IE zoom instead of resizing and so the technique is never used. If someone does try it on a Mac please report back.

Using Your Own Url Shortener
Short url?
4 comments
page 1190
Why I Ditched Disqus
Styling disqus widgets?
5 comments
page 1175
Wordpress 25 Exif Fields
Wordpress exif?
12 comments
page 230
Html 5 Gallery
Html 5 gallery?
6 comments
page 1305
Dont Mess With My Toot Toot
Fun with toots?
16 comments
page 599
Dont Mess With My Toot Toot
Fun with toots?
16 comments
page 599
Converting Wordpress Themes To Habari
Habari timthumb?
one comment
page 694
Wordpress 25 Exif Fields
Habari timthumb?
12 comments
page 230
Fun With Sidebar Tabs Styling
Tabs with html css on same page javascript?
2 comments
page 336
Using Your Own Url Shortener
How to have own url short?
4 comments
page 1190
Post Image The Easy Peasy Way
Insert conditional image php wp?
26 comments
page 1065
How To Add Sidebars To A Theme
Wordpress sidebar above main sidebars?
11 comments
page 1053
Using Your Own Url Shortener
Run short url using htaccess?
4 comments
page 1190
Dont Mess With My Toot Toot
New posttype not displayed wordpress?
16 comments
page 599
Quick N Dirty Replacement Text
Wpupdatepost object?
no comment
page 122
Html 5 Gallery
Html5 simple wordpress theme?
6 comments
page 1305
Updating Code Snippets Here
Fun wordpress plugin?
one comment
page 1338
How To Add Sidebars To A Theme
Wp register sidebars?
11 comments
page 1053
Html 5 Gallery
Html5 wordpress theme?
6 comments
page 1305
Post Image The Easy Peasy Way
Get post images?
26 comments
page 1065
Updating Code Snippets Here
Wordpress fun plugins?
one comment
page 1338
Post Image The Easy Peasy Way
Wordpress get first image large?
26 comments
page 1065
Using Wordpress As A Php Framework
Wordpress create your own framework?
2 comments
page 335
Improve Your Typography With Plugins
Wordpress typography plugin?
one comment
page 721
Quick N Dirty Replacement Text
Dirty replacement?
no comment
page 122
Post Image The Easy Peasy Way
Get attachment by post?
26 comments
page 1065
How To Add Sidebars To A Theme
How to add pages in footer wordpress?
11 comments
page 1053
Html 5 Gallery
Html 5 tab?
6 comments
page 1305
Wordpress 25 Exif Fields
Exif info display wordpress?
12 comments
page 230
Using Your Own Url Shortener
Tiny urls htaccess?
4 comments
page 1190
Post Image The Easy Peasy Way
How to post all gallery images in one post wordpress?
26 comments
page 1065
Six Million Ways To Die Choose One
6 million ways to die so i chose?
14 comments
page 1128
How To Add Sidebars To A Theme
Wp register sidebars?
11 comments
page 1053
  1 query every 1444 seconds, updated 1 seconds ago.
Post a comment?