CSS3
CSS3 背景
在 content-box 中定位背景图片
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> div { border: 1px solid black; padding: 35px; background-image: url("/examples/smiley.gif"); background-repeat: no-repeat; background-position: left; } #div1 { background-origin: border-box; } #div2 { background-origin: content-box; } </style> </head> <body> <p>背景图像边界框的相对位置:</p> <div id="div1"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. </div> <p>背景图像的相对位置的内容框:</p> <div id="div2"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. </div> </body> </html>
运行结果:
点击运行 »