爱问知识人 爱问教育 医院库

网页制作中如何实现图片在div内垂直水平居中

首页

网页制作中如何实现图片在div内垂直水平居中

网页制作中如何实现图片在div内垂直水平居中

提交回答

全部答案

    2019-06-18 10:13:29
  •   如果你仅仅是想让图片居中,最简单的方法是设为背景图片,如:
    div {
        width:500px;border:1px solid #f00;
        height:500px;
        background:url("/images/logos。
      gif") center no-repeat } 如果要实现图片在div内垂直水平居中,代码如下: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title></title> <style type="text/css"> 。
      img_v { display:table-cell !important; display:block; position:static !important; position:relative; overflow:hidden; width:400px; height:400px; border:1px solid #000; vertical-align:middle; text-align:center; } 。
      img_v p { display:table-cell !important; display:block; margin:0; position:static !important; position:absolute; top:50%; left:50%; width:400px; margin-left:auto; margin-right:auto; } 。
      img_v img { position:static !important; position:relative; top:auto !important; top:-50%; left:auto !important; left:-50%; } </style> </head> <body> <div class="img_v"> <p><img src="/images/logos。
      gif"></p> </div> </body> </html>。

    一***

    2019-06-18 10:13:29

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):