• <noscript id="ecgc0"><kbd id="ecgc0"></kbd></noscript>
    <menu id="ecgc0"></menu>
  • <tt id="ecgc0"></tt>

    怎么使用CSS讓圖片水平垂直都居中?

    CSS是層疊樣式表。下面,我們來看看怎么使用CSS讓圖片水平垂直都居中吧。

    操作方式

    • 01

      新建一張文檔
      在桌面新建一張文本文檔,更名為1.txt,如下圖所示:

    • 02

      根本代碼
      然后打開文本文檔,編寫根本代碼,再把桌面上的山君圖片引入進去,如下圖所示:

    • 03

      后綴名
      然后把文本文檔后綴名改為.html,如下圖所示:

    • 04

      運行網頁
      然后在瀏覽器中運行網頁,此刻圖片有了,只是還沒有居中,圖片棲身代碼要用CSS寫,如下圖所示:

    • 05

      CSS代碼
      然后寫上CSS代碼,如下圖所示:

    • 06

      垂直程度居中
      可以看到圖片已經垂直和程度居中,如下圖所示:

    • 07

      總代碼
      <!DOCTYPE html>

      <head>

      <title>html</title>
      <style type="text/css">
      .picTiger{
      margin: auto;
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      }

      </style>
      </head>

      <body>

      <img class="picTiger" src="C:/Users/Administrator/Desktop/1.png">

      </body>

      <html>

    • End
    • 發表于 2018-12-09 00:00
    • 閱讀 ( 784 )
    • 分類:電腦網絡

    你可能感興趣的文章

    相關問題

    0 條評論

    請先 登錄 后評論
    聯系我們:uytrv@hotmail.com 問答工具
  • <noscript id="ecgc0"><kbd id="ecgc0"></kbd></noscript>
    <menu id="ecgc0"></menu>
  • <tt id="ecgc0"></tt>
    久久久久精品国产麻豆