<delect id="sj01t"></delect>
  1. <em id="sj01t"><label id="sj01t"></label></em>
  2. <div id="sj01t"></div>
    1. <em id="sj01t"></em>

            <div id="sj01t"></div>

            html元素水平居中的方法

            時間:2025-09-30 04:29:36 網頁設計

            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 "-/pic/pic/pic/pic/TR/xhtml1/DTD/xhtml1-transitional.dtd">

              <html xmlns="/pic/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居中浮動元素的使用方法11-28

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

            CSS 如何使p層水平居中02-03

            用CSS讓DIV層水平居中實例12-13

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

            php過濾危險html代碼的方法11-23

            html5的canvas方法使用01-19

            HTML5學習方法11-11

            學習HTML5方法09-29

            <delect id="sj01t"></delect>
            1. <em id="sj01t"><label id="sj01t"></label></em>
            2. <div id="sj01t"></div>
              1. <em id="sj01t"></em>

                      <div id="sj01t"></div>
                      黄色视频在线观看