W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <head> <style> #example1 { border: 1px solid black; background: url(/i/photo/flower.gif); background-size: 100px 80px; background-repeat: no-repeat; padding: 15px; } #example2 { border: 1px solid black; background: url(/i/photo/flower.gif); background-repeat: no-repeat; padding: 15px; } </style> </head> <body> <h1>background-size 属性</h1> <p>被调整大小的 background-image:</p> <div id="example1"> <h2>Welcome to Shanghai</h2> <p>Shanghai is one of the four direct-administered municipalities of the People's Republic of China. Welcome to Shanghai!</p> <p>The city is located on the southern estuary of the Yangtze, with the Huangpu River flowing through it.</p> </div> <p>background-image 的原始尺寸:</p> <div id="example2"> <h2>Welcome to Shanghai</h2> <p>Shanghai is one of the four direct-administered municipalities of the People's Republic of China. Welcome to Shanghai!</p> <p>The city is located on the southern estuary of the Yangtze, with the Huangpu River flowing through it.</p> </div> </body> </html>