By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,253 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,253 IT Pros & Developers. It's quick & easy.

how image can be vertically centralized in browser in any resolution.

P: 1
Please if find any one...
Feb 14 '11 #1
Share this Question
Share on Google+
3 Replies


Ashwani Sharma
P: 46
I've static solution for this, means if you know the size of your image which you want to centralized. suppose your image size is 200px, you can use this css:

.abc{
position:absolute;
float:left;
height:200px;
top:50%;
margin-top:-100px;
}

this will work for your problem if there is static images but if the images will come dynamically then you have to use this same css calculation using JS or any other development tool.

Regards,
Ashwani Sharma
Feb 14 '11 #2

P: 27
or just div it with margin:auto;

for a background just add:

background-attachment:fixed;
background-position:center;
Feb 20 '11 #3

P: 14
NetDynamic: That's the best solution for centering something horizontal, and doesn't work when you want to center something vertically.
Feb 22 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.