Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: DHTML
Expertise: Beginner
Sep 24, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Place Image in an Absolute Position


I've been using the Microsoft ActiveX image control to place my images in absolute positions on my Web page. However, I have run into problems with this image component on some PCs. I have tried to reregister the ISCTRLS.OCX, which contains this component, but this does not help. Can you give me an example on how to place an image in an absolute position without using an explicit ActiveX image component?


You can use a DHTML-specific technique to position the image absolutely that will work with IE 4.x and up and Navigator 4.x and up, or any other browser that supports CSS absolute positioning (CSS-P or CSS2). Create an absolutely positioned DIV or SPAN section and place the image within this section. The section, including the image, will be positioned at the location you supply in the CSS style setting. For instance, this code would position the image at 100 pixels from the left and 100 pixels from the top of the browser document:

Unfortunately, this approach won't work for any browser that doesn't support CSS Positioning (or CSS2) such as IE 3.x—the ActiveX image control did work with IE 3.x.

DevX Pro
Thanks for your registration, follow us on our social networks to keep up-to-date