Jump to content

HOW TO CENTER DIV WITH ABSOLUTE POSITION?


onenonly

Recommended Posts

I tried using CSS

 

left: 50%;

margin-left: <half image width>;

 

But i need margin left to be dynamic because I will be using different images

the width of each image is different so i need to change margin left everytime

 

I tried using javascript

document.getElementById('box').style.marginleft = myImage.width/2;

this doesnt work

 

any idea on best way of achieving this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.