純css完美實現圖片在div內垂直水平置中

來源:互聯網
上載者:User

以下是要實現插入圖片的絕對置中,如果你僅僅是想讓圖片置中,最簡單的方法是設為背景圖片,如:

div {
    width:500px;border:1px solid #f00;
    height:500px;
    background:url("/images/logos.gif") center no-repeat
    }

言歸正轉,請看以下代碼實現圖片在div內垂直水平置中:

以下是HTML網頁特效代碼,點擊運行按鈕可查看效果:
[Ctrl+A 全部選擇 提示:你可先修改部分代碼,再按運行]



相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.