how do i vertically a picture in html?

im making something for some1 and i need to no how to verically center a picture this is the code i have so far: <div style="background-color:pink;width:400px;height:600px;"> <img src="http://i169.photobucket.com/albums/u208/jodiisyourfriend_3/BananasinPajamas.jpg"> </div>

Public Comments

  1. <center> <img src="http://i169.photobucket.com/albums/u208/jodiisyourfriend_3/BananasinPajamas.jpg%22%3E"> </center>
  2. <table border=0 width=100% height=100%> <tr> <td valign=middle align=center> <p> <IMG SRC="your image.jpg" alt="yours"/> <p> </td> </tr> </table>
  3. 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.... <div style="background-color:pink; width:400px; height:600px; background-image:url(http://i169.photobucket.com/albums/u208/jodiisyourfriend_3/BananasinPajamas.jpg); background-repeat:no-repeat; background-position:center center">Text or content for the div, if any, goes here.</div> (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/
  4. The above code only horizontally centers the picture. To vertically center a picture in a div block, use a virtual table: ----------------------- <div class="someDiv"> <div> <img src="myimage.jpg"/> </div> </div> ----------------------- 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; ------------------------
  5. 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
Powered by Yahoo! Answers