源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <style> body { background-image:url('img_tree.png'); background-repeat:no-repeat; background-position:right top; margin-right:200px; } </style> </head> <body> <h1>Hello World!</h1> <p>背景圖片不重復,設置 position 實例。</p> <p>背景圖片只顯示一次,併與文本分開。</p> <p>實例中還添加了 margin-right 屬性用於讓文本與圖片間隔開。</p> </body> </html>
運行結果