您好,欢迎访问一九零五行业门户网

深入了解CSS中边偏移属性top,right,bottom,left的详细用法

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>
以上就是深入了解css中边偏移属性top,right,bottom,left的详细用法的详细内容。
其它类似信息

推荐信息