Home arrow HTML arrow Maximizing and Restoring HTML Images with the Absolute Method
HTML

Maximizing and Restoring HTML Images with the Absolute Method


Have you ever wanted to display an image on your web page that can be maximized and restored within the same page? Well, this article will show you how to do just that with JavaScript and Cascading Style Sheets. Prepare yourself for the Absolute Method.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 5
April 09, 2008
TABLE OF CONTENTS:
  1. · Maximizing and Restoring HTML Images with the Absolute Method
  2. · Accomplishing it with JavaScript and CSS
  3. · Accomplishing it with JavaScript and CSS continued
  4. · Testing and Finalizing

print this article
SEARCH DEVARTICLES

Maximizing and Restoring HTML Images with the Absolute Method
(Page 1 of 4 )

The phenomenon

You must have come across web pages with images that can be enlarged (maximized) and restored within the same page. There is normally a small clickable area on the image. When you click this area, the image is maximized. When the image is maximized, there is a small clickable area on the image that restores the image to its original size if clicked. This phenomenon is common in e-commerce or shopping web sites.

One way to have this done on your web page is to obtain (buy) a program that will produce the image with the small clickable area. When this area is clicked, the image will maximize or restore itself. You do not need to know how the program was written; you just use it to produce an image with the maximization and restoration characteristics. You can also do it yourself using JavaScript and Cascading Style Sheets. That is what I want to show you in this article. I call this the Absolute Method.

You need to know the basics of HTML, JavaScript, and CSS in order to understand this method. I will use the image of a watch to explain the method. Two sizes of a watch image are given below (Fig.1 & Fig.2). The small one is the watch at its normal size. The bigger one is the watch at the maximized size.




The small square with a black border at the bottom right of the normal sized image is the clickable area that allows you to maximize the image. The small overlapped squares at the bottom right of the maximized image let you restore the image to the smaller size.

The method (Absolute Method)

This is how the whole method works: there is the main image of interest, like the image of a watch, that will be maximized. There is a small image with the maximization symbol (square) and this image is made clickable (explained below). There is another small image with the restoration symbol (overlapped squares) and it is also made clickable. So there are three images. The restored and maximized sizes of the main image of interest are controlled via CSS (see below).

The small image that is to be maximized is superimposed at the bottom right of the main image. When you click the small image, a JavaScript function is called. This function uses a CSS property to change (increase) the dimensions of the main image. I explain how to avoid resolution loss below. The function then hides the small maximization image. This same function now makes the small restoration image visible at the bottom right of the main image. The small restoration image was initially hidden.

If you click this small restoration image, another JavaScript function is called. This function uses a CSS property to change (decrease) the dimensions of the main image to its original form. This function now hides the restoration image and makes the maximized image visible.


blog comments powered by Disqus
HTML ARTICLES

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials