久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      html5中怎么實(shí)現(xiàn)居中顯示圖片

      圖片居中方法:1、利用“margin:0 auto”實(shí)現(xiàn)水平居中;2、利用“text-align:center”實(shí)現(xiàn)水平居中;3、利用line-height實(shí)現(xiàn)垂直居中;4、利用table實(shí)現(xiàn)垂直居中;5、利用position實(shí)現(xiàn)垂直居中。

      html5中怎么實(shí)現(xiàn)居中顯示圖片

      本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。

      一、首先,我們來(lái)看看css圖片水平居中的方法

      1、利用margin:0 auto實(shí)現(xiàn)圖片水平居中

      html圖片水平居中代碼:

      <div style="text-align:center;width:500px;border:greensolid1px;"> <img alt="" src="http://img0.imgtn.bdimg.com/it/u=1768770686,623173162&fm=26&gp=0.jpg"  style="margin:0 auto;"/> </div>

      2、利用文本的水平居中屬性text-align:center實(shí)現(xiàn)圖片水平居中

      html圖片水平居中代碼:

      <div> <div style="text-align:center;width:500px;border:greensolid1px;"> <img alt="" src="http://img0.imgtn.bdimg.com/it/u=1768770686,623173162&fm=26&gp=0.jpg"  style="display:inline-block;"/> </div>

      二、我們來(lái)看看css圖片垂直居中的實(shí)現(xiàn)方法

      1、利用line-height實(shí)現(xiàn)圖片垂直居中

      html圖片垂直居中代碼如下:

      <div style="text-align:center;width:500px;height:200px;line-height:200px;border:greensolid1px;"> <img alt="" src="http://img0.imgtn.bdimg.com/it/u=1768770686,623173162&fm=26&gp=0.jpg" style="display:inline-block;vertical-align:middle;"/> </div>

      注意:此種方法需要注明高度才可以使用。

      2、利用table實(shí)現(xiàn)圖片垂直居中

      html圖片垂直居中代碼如下:

      <div style="text-align:center;width:500px;height:200px;display:table;border:greensolid1px;"> <span style="display:table-cell;vertical-align:middle;"> <img alt="" src="http://img0.imgtn.bdimg.com/it/u=1768770686,623173162&fm=26&gp=0.jpg" style="display:inline-block;"/> </span> </div>

      注意:此種方法是利用了table的垂直居中屬性

      說(shuō)明:這里使用display:table;display:table-cell;來(lái)模擬table,這種方法并不兼容IE6/IE7,IE67不支持display:table,如果你不需要支持IE67那就可以用

      這種方法有一個(gè)缺點(diǎn):當(dāng)你設(shè)置了display:table;可能會(huì)改變你的原有布局

      3、利用position實(shí)現(xiàn)圖片垂直居中

      html圖片垂直居中代碼如下:

      <div style="width:500px;height:200px;position:relative;border:greensolid1px;"> <img alt="" src="http://img0.imgtn.bdimg.com/it/u=1768770686,623173162&fm=26&gp=0.jpg" style="width:120px;height:40px;position:absolute;left:50%;top:50%;margin-left:-60px;margin-top:-20px;"/> </div>

      說(shuō)明:如果已知圖片的寬度和高度可以用這種方法。

      推薦學(xué)習(xí):html5視頻教程

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)