HighDots Forums  

Rotating images via CSS - doable?

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Rotating images via CSS - doable? in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mike J.S.
 
Posts: n/a

Default Rotating images via CSS - doable? - 09-10-2007 , 04:48 PM






Say I'm using PNGs to create rounded corner boxes... can CSS be used to
"rotate" the same PNG 3 times to cover all 4 corners, or must I link to 4
different images?

Must work in FF1+ & IE6+ in both Win/Mac.



Reply With Quote
  #2  
Old   
Michael Fesser
 
Posts: n/a

Default Re: Rotating images via CSS - doable? - 09-10-2007 , 06:24 PM






..oO(Mike J.S.)

Quote:
Say I'm using PNGs to create rounded corner boxes... can CSS be used to
"rotate" the same PNG 3 times to cover all 4 corners, or must I link to 4
different images?
You can't rotate an image with CSS, but sometimes you can combine
multiple images into a single one and use CSS to only show a part of it.
With a little thinking the techniques described on

Fast Rollovers Without Preload
http://wellstyled.com/css-nopreload-rollovers.html

and

CSS Sprites: Image Slicing’s Kiss of Death
http://www.alistapart.com/articles/sprites/

can also be used for corner and border images. But how and which images
can be combined also depends on the HTML structure and the elements they
are applied to.

I played around with that a while ago. A fully customized border around
a box (with 4 borders, 4 corners, all done with images) can be achieved
with only 4 image files and some CSS rules, as seen in this example:

http://mfesser.de/test/borders/

This (experimental!) example makes heavy use of child and adjacent
sibling selectors and PNG transparency, so it requires a modern browser
(no way in IE 6). There are only two images for the borders and two for
the corners. The rest (positioning, repeating) is done with CSS.

The CSS is "compressed" and narrowed down to the absolute minimum. I
recommend to use the DOM Inspector in Firefox (or a similar tool) to see
how it actually works and which CSS rules apply to which element.

Directory browsing is enabled to make it easier to have a look at the
used files:

http://mfesser.de/test/borders/images/
http://mfesser.de/test/borders/style/

HTH
Micha


Reply With Quote
  #3  
Old   
Mike J.S.
 
Posts: n/a

Default Re: Rotating images via CSS - doable? - 09-10-2007 , 07:09 PM



Intriguing concept. I wonder if the added calculations of the code outweight
the loading of 1 image instead of 4.

Unfortunately, the site has to work on IE6 (and Mac) so it's a moot point,
but as I said, it's an intriguing concept.

"Michael Fesser" <netizen (AT) gmx (DOT) de> wrote

Quote:
.oO(Mike J.S.)

Say I'm using PNGs to create rounded corner boxes... can CSS be used to
"rotate" the same PNG 3 times to cover all 4 corners, or must I link to 4
different images?

You can't rotate an image with CSS, but sometimes you can combine
multiple images into a single one and use CSS to only show a part of it.



Reply With Quote
  #4  
Old   
Michael Fesser
 
Posts: n/a

Default Re: Rotating images via CSS - doable? - 09-10-2007 , 07:24 PM



..oO(Mike J.S.)

Quote:
Intriguing concept. I wonder if the added calculations of the code outweight
the loading of 1 image instead of 4.
I think so. An additional HTTP request causes much more overhead and
delay than a rather simple CSS calculation.

Quote:
Unfortunately, the site has to work on IE6 (and Mac) so it's a moot point,
but as I said, it's an intriguing concept.
It can be made work in IE6 (don't know about IE/Mac, I can't test it and
actually I don't really care about that one). It just requires some more
classes or IDs, because of IE's lacking support for the more advanced
CSS selectors. Instead of accessing an element just by using child or
other selectors, you would have to give it a class or ID. But the main
concept of having multiple images in one ("sprites") works even in IE.

Micha


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.