陪你做好前端设计!
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta charset="utf-8"> <title>素材8网教程(study.sucai8.cn)</title> <style> div { width: 100%; height: 400px; background-image: url('/images/img_flowers.jpg'); background-repeat: no-repeat; background-size: contain; border: 1px solid red; } </style> </head> <body> <p>调整浏览器大小查看效果。</p> <div></div> </body> </html>
运行结果