首页
极刻
圈子
教程
开源
登录 / 注册
返回教程:CSS 教程
TRY RUN / 在线示例
CSS 教程 尝试一下
CSS 教程 尝试一下
源代码
运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>安科教程(www.ancii.com)</title> <style> h2.pos_left { position:relative; left:-20px; } h2.pos_right { position:relative; left:20px; } </style> </head> <body> <h2>This is a heading with no position</h2> <h2 class="pos_left">This heading is moved left according to its normal position</h2> <h2 class="pos_right">This heading is moved right according to its normal position</h2> <p>Relative positioning moves an element RELATIVE to its original position.</p> <p>The style "left:-20px" subtracts 20 pixels from the element's original left position.</p> <p>The style "left:20px" adds 20 pixels to the element's original left position.</p> </body> </html>
运行结果