The apple effect for overlay
Here you can see an Apple effect in action:
Apple effect performs overlaying in a visually appealing manner by growing a background image from 0 to the desired size. This differs from "regular" overlaying solutions that do overlaying with static DIVs. The downside is that you are tied to the dimensions of the image. You can change the width but the height scales accordingly so that the aspect ratio remains constant.
HTML setup
The HTML setup is identical to the minimal setup for overlay. There are trigger elements and their corresponding overlay elements.
CSS coding
Some important things about the CSS coding of this effect:
- This effect requires that your overlay element uses a background image whose width is grown from zero to the desired size. The background image is defined for the overlay element using the backgroundImage CSS property.
- The close button is automatically generated by the overlay tool with the CSS class name close which you can use to style it. You can alter the class name from the configuration.
- The zIndex parameter is given in the overlay configuration and not in the CSS in contrast to the default effect. This parameter is specified for the growing image and the close button and the overlay contents are automatically given a value one greater so they will appear above the background image.
- You can use absolute positioning of the elements inside the overlay and those elements are positioned relative to the overlay element. This is because the overlay is also absolutely positioned. This is how CSS works.
We are using the overlay-apple.css stylesheet which looks like this:
You can use any browser-renderable background image with overlay. However, using PNG images allows you to have neat drop shadows in your overlays, since PNG supports alpha transparency, while GIF and JPG images do not. You can use the same background image at different sizes without experiencing significant quality degradation.
IE6 issues
IE6 does not support alpha-transparency for the overlays so we have used a different background for that browser:
Black "skin"
You can easily change the look of the overlay simply by changing the background image. In our example above we used black and white backgrounds. For the black overlay we have the class name "black" and its configuration is here:
JavaScript coding
Here is the overlay configuration. We specify our "apple" effect with the effect configuration variable.
Note: this effect is not included in the standard jQuery Tools distribution. You must download a custom combination that includes this effect.