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
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

Link to comment
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

 

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.