Jump to content

Div exactly in the centre of the Screen


desibhupi

Recommended Posts

I have made a javascript that opens a picture in Div (absolute positions mentioned in css)

 

I want to show this image in this specific div but exactly in the center (horizontally and vertically) of the bowser screen.

 

Can anybody help in this regards,

 

Thanx in advance :)

Bhupinder

Link to comment
https://forums.phpfreaks.com/topic/39903-div-exactly-in-the-centre-of-the-screen/
Share on other sites

no do not use lightbox this is easy to accomplish with css just set your margin to auto in all cases using css example

 

<div style="margin:auto auto;"></div>

 

this should accomplish what you are looking for.

 

Also kind of off subject but lightbox is a horibble way to accomplish what it does, since it uses prototypes that contain way to much code then you need. ;)

 

Anyways hope this helped

no do not use lightbox this is easy to accomplish with css just set your margin to auto in all cases using css example

 

<div style="margin:auto auto;"></div>

 

this should accomplish what you are looking for.

 

Also kind of off subject but lightbox is a horibble way to accomplish what it does, since it uses prototypes that contain way to much code then you need. ;)

 

Anyways hope this helped

 

This in theory works; however, since top and bottom auto margins do not display properly in any modern browsers yet, you'll have to come up with something different. Read up on the W3 Vertical Centering page for the methods of centering things that are available. Hopefully, with CSS3, there will be additional options.

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.