老师,关于背景图片缩放的问题。

来源:4-1 课程总结

qq_江_3

2017-06-27 08:59:01

我的背景图片是1681*1087像素。 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>css background</title> <style type="text/css"> div{ width: 50%; background: #000000 url(picture/1.jpg) no-repeat center; } </style> </head> <body> <div>this is background <ul> <li>电视</li> <li>冰箱</li> <li>洗衣机</li> <li>空调</li> </ul> </div> </body> </html>

 我已经设置width:50% 为什么我的背景图片在宽度上没有进行缩放,而是只显示了图片一半的内容。

写回答

2回答

天道酬勤168

2017-07-02

2个办法:1、设置width为100%。2、更改背景图片大小background-size:50%。

0

小于飞飞

2017-06-27

你好, 使用的是背景图,默认是平铺其容器,同时div 设置的 宽是 50%, 不是图片的宽设置50% ,可以添加 background-size: 50%; 来设置背景图大小,希望对你有帮助,祝学习愉快,欢迎采纳。

0

0 学习 · 36712 问题

查看课程