<pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

          <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

          <p id="bbfd9"></p>

          <p id="bbfd9"><cite id="bbfd9"></cite></p>

            <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

            <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
            <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
            網頁設計

            html元素水平居中的方法

            時間:2025-04-25 11:27:00 網頁設計 我要投稿
            • 相關推薦

            html元素水平居中的方法

              html元素有哪些?水平居中于其父級元素的方法你是否知道呢?就讓小編來告訴你們哦!

              方法1:

              代碼如下:

              <p class="wrap">

              <p class="left-right-middle1">左右居中方法1</p>

              </p>

              代碼如下:

              html,body,p{

              margin:0;

              padding:0;

              height:100%;

              position:relative;

              }

              .wrap{

              width:400px;

              height:300px;

              margin:10px;

              border:1px solid #000;

              }

              .left-right-middle1{

              width:200px;

              background-color:#69F;

              margin:0 auto;

              }

              方法2:

              代碼如下:

              <p class="wrap">

              <p class="left-right-middle2">左右居中方法2</p>

              </p>

              代碼如下:

              html,body,p{

              margin:0;

              padding:0;

              height:100%;

              position:relative;

              }

              .wrap{

              width:400px;

              height:300px;

              margin:10px;

              border:1px solid #000;

              }

              .left-right-middle2{

              width:200px;

              background-color:#69F;

              left:50%;

              margin-left:-100px;

              }

              html元素 垂直居中 于 其父級元素的方法:

              代碼如下:

              <p class="wrap">

              <p class="top-bottom-middle">上下居中</p>

              </p>

              代碼如下:

              html,body,p{

              margin:0;

              padding:0;

              height:100%;

              position:relative;

              }

              .wrap{

              width:400px;

              height:300px;

              margin:10px;

              border:1px solid #000;

              }

              .top-bottom-middle{

              height:200px;

              background-color:#69F;

              top:50%;

              margin-top:-100px;

              }

              html元素 水平垂直居中 于 其父級元素的方法:

              方法1:

              代碼如下:

              <p class="wrap">

              <p class="all-middle1">上下左右居中方法1</p>

              </p>

              代碼如下:

              html,body,p{

              margin:0;

              padding:0;

              height:100%;

              position:relative;

              }

              .wrap{

              width:400px;

              height:300px;

              margin:10px;

              border:1px solid #000;

              }

              .all-middle1{

              width:200px;

              height:200px;

              background-color:#69F;

              top:50%;

              margin:-100px auto 0;

              }

              方法2:

              代碼如下:

              <p class="wrap">

              <p class="all-middle2">上下左右居中方法2</p>

              </p>

              代碼如下:

              html,body,p{

              margin:0;

              padding:0;

              height:100%;

              position:relative;

              }

              .wrap{

              width:400px;

              height:300px;

              margin:10px;

              border:1px solid #000;

              }

              .all-middle2{

              width:200px;

              height:200px;

              background-color:#69F;

              top:50%;

              left:50%;

              margin:-100px 0 0 -100px;

              }

              完整代碼:

              代碼如下:

              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

              <html xmlns="http://www.w3.org/1999/xhtml">

              <head>

              <meta http-equiv="Content-Type" content="text/html" charset="utf-8" />

              <title>p Middle</title>

              <style type="text/css">

              html,body,p{

              margin:0;

              padding:0;

              height:100%;

              position:relative;

              }

              .wrap{

              width:400px;

              height:300px;

              margin:10px;

              border:1px solid #000;

              }

              .left-right-middle1{

              width:200px;

              background-color:#69F;

              margin:0 auto;

              }

              .left-right-middle2{

              width:200px;

              background-color:#69F;

              left:50%;

              margin-left:-100px;

            【html元素水平居中的方法】相關文章:

            CSS居中浮動元素的使用方法05-31

            div水平垂直居中顯示01-19

            CSS 如何使p層水平居中04-28

            用CSS讓DIV層水平居中實例05-16

            用CSS讓p層水平居中實例04-08

            html5的canvas方法使用01-19

            HTML5學習方法05-02

            php過濾危險html代碼的方法05-31

            html5的學習方法指導03-01

                    <pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

                    <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

                    <p id="bbfd9"></p>

                    <p id="bbfd9"><cite id="bbfd9"></cite></p>

                      <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

                      <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
                      <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
                      飘沙影院