简体   繁体   中英

displaying image in the center of the screen in iphone webview using css, html

Am using html, css to display an image.

IMG.displayed {
    display: block;
    margin-left: auto;
    margin-right: auto;
    vertical-align: middle
}
 <IMG class="displayed" src="../images/splash.png" alt="...">
 </IMG>

Its not displaying the image in the center of the screen (both vertically & horozontally).

your suggestions please.

To align an element both vertically & horizontally you could use the snippet below:

http://jsfiddle.net/catalinred/huKYW/

or

HTML:

<div>content here</div>

CSS

div
{
  width: 300px;
  height: 300px;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -150px;
  margin-top: -150px;
  background: red;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM