views:

72

answers:

1

Hi,

I'm putting together a book flip where I flip pages using CSS, JavaScript and HTML. It works very well, except for this one thing.

Every image has a block-level parent. The block-level parent's dimensions has the same ratio as the image but it's scaled down to fit inside the window. Every image has a width:100%; and height:100%; declaration making it fit directly inside its block-level parent.

Now, this works great but when I start sliding the pages the animation's VERY slow and laggish because I scale the images down. If I remove the width and height declaration from the images the animation runs smoothly but the images exceed their block-level parent's dimensions.

What can I do to fix this? Creating a new image with new dimensions isn't an option since I want the images to fit inside every screen resolution.

The animation is only slow in the following browsers/OS'es: Opera 10, Mac Chrome 6, Mac Firefox 3, Windows

Safari 5 and Firefox 3 on Mac and IE7 on Windows handle the animation very well but there are some browsers, where the performance gets killed when scaling down images.

A: 

I'm not sure if this will work in your use-case, but have you tried setting the images/blocks to display: absolute or display: fixed?

Because absolute and fixed elements are not in the flow, they do not cause reflows when their properties change, so that can drastically help speed things up, depending on the circumstances.

Could we see a little code, or maybe a live example?

Pauan