<html> <head> <style type="text/css"> body { background-image:url('http://img.gaodaima.com/paperimg_gaodaima_eg_bg_03.gif'); background-repeat:no-repeat; background-attachment:fixed; background-position: 60% 50%; } </style> </head> <body> <body> <p><b>提示:</b>您需要把 background-attachment 属性设置为 "fixed",才能保证该属性在 Firefox 和 Opera 中正常工作。</p> </body> </body> </html>
本文案例为大家展示了如何使用百分比来在页面上定位背景图像的代码,若要看代码效果请大家点击“运行代码”按钮。
[code]<html> <head> <style type=”text/css”> body { background-image:url(‘http://img.gaodaima.com/paperimg_gaodaima_eg_bg_03.gif’); background-repeat:no-repeat; background-attachment:fixed; background-position: 60% 50%; } </style> </head> <body> <body> <p><b>提示:</b>您需要把 background-attachment 属性设置为 “fixed”,才能保证该属性在 Firefox 和 Opera 中正常工作。</p> </body> </body> </html>[/code]