CSS
响应式 Web 设计 - 图片
这是 CSS 代码
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta charset="utf-8"> <style> div { width: 100%; height: 400px; background-image: url('/wp-content/uploads/2015/06/img_flowers.jpg'); background-repeat: no-repeat; background-size: contain; border: 1px solid red; } </style> </head> <body> <p>调整浏览器大小查看效果。</p> <div></div> </body> </html>
运行结果:
点击运行 »