Question:
how do i vertically a picture in html?
slimshorty_101
2007-08-10 21:03:17 UTC
im making something for some1 and i need to no how to verically center a picture
this is the code i have so far:


Five answers:
Ron
2007-08-10 21:39:39 UTC
The above code only horizontally centers the picture. To vertically center a picture in a div block, use a virtual table:

-----------------------











-----------------------

together with the following style:

-----------------------

#someDiv {top: 0; left: 0; width: 100%; height: 100%;

position: fixed; display: table}

#someDiv div {display: table-cell; vertical-align: middle}



-----------------------

To horizontally center as well, give the img element a style of:

-----------------------

display:block;

margin-left:auto;

margin-right:auto;

------------------------
joyaz711
2007-08-10 21:30:01 UTC
There is no way to vertically align in a div - in a table cell the default is to align in the middle.



With the div, you could set the background image as the bananas like this....



Text or content for the div, if any, goes here.




(had to split it to separate lines to get the code to show here) Give that a try and see if that's what you're trying to do.



Joyce

http://www.DesignByJoyce.com/
I.M.
2007-08-10 22:06:58 UTC
as long as U don't have to size of a HTML page U can't do that but U can simply create a table that the width and height of it is 100% then create a cell on it on the only row of it and make this cell valign = middle
zircon
2007-08-10 21:20:15 UTC












yours



Jaren S
2007-08-10 21:11:36 UTC






This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...