深入瞭解CSS中邊位移屬性top,right,bottom,left的詳細用法

來源:互聯網
上載者:User
1:上邊位移屬性

用來定義元素頂部位移位置的大小。top: auto | length | percent

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title> CSS屬性執行個體 </title>  <meta name="Generator" content="EditPlus">  <meta name="Author" content="">  <meta name="Keywords" content="">  <meta name="Description" content="">  <style>    p{  top: 100px;  position: absolute;  border: 2px solid #333333;  background: #666666;  width: 300px;  height: 50px;}  </style> </head> <body>   <p>這是使用邊位移屬性的執行個體</p> </body></html>


2:右邊位移屬性right

用來定義元素右側位移位置的大小。right: auto | length | percent;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title> css屬性執行個體 </title>  <meta name="Generator" content="EditPlus">  <meta name="Author" content="">  <meta name="Keywords" content="">  <meta name="Description" content="">  <style>    p{  right: 100px;  position: absolute;  border: 2px solid #333333;  background: #666666;  width: 300px;  height: 50px;}  </style> </head> <body>  <p>這是使用邊位移屬性的執行個體</p> </body></html>



3:下邊位移屬性bottom

用來定義底部位移位置的大小。bottom:auto | length | percent;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title> css屬性執行個體 </title>  <meta name="Generator" content="EditPlus">  <meta name="Author" content="">  <meta name="Keywords" content="">  <meta name="Description" content="">  <style>    p {  bottom: 100px;  position: absolute;  border: 2px solid #333333;  width: 300px;  height: 50px;    }  </style> </head> <body>  <p>這是使用下邊位移屬性bottom</p> </body></html>



4:左邊位移屬性left

用來定義元素左邊位移位置的大小,left: auto | length | percent;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title> New Document </title>  <meta name="Generator" content="EditPlus">  <meta name="Author" content="">  <meta name="Keywords" content="">  <meta name="Description" content="">  <style>     p { left: 100px; position: absolute; border: 2px solid #333333; background: #666666; width: 300px; height: 50px; }  </style> </head> <body>   <p>這是使用左邊位移屬性的執行個體</p> </body></html>

相關文章

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.