html中div元素的图像背景 [英] image background of div element in html

查看:68
本文介绍了html中div元素的图像背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
我在html页面中有一个"div"元素.div的"width属性"基于百分比,例如"width:80%",我想将图片设置为div的背景属性.
我有一个宽度为1000px的图像,所以我想图像宽度随div的宽度而变化.
那我该怎么做?

hi.
i have a "div" element in my html page.the "width property" of div is based on percent e.g "width:80%",i wanna set a image to div''s background property.
i have a image that its width is 1000px so i wanna image width change with width of div.
so how i do it?

thank.

推荐答案

如何使用background-size属性?

您可以使背景为拉伸,平铺或都不为背景.查看此属性的"cover","contain"和"100%"值.
How about you use the background-size property?

You can have the background either stretch, tile or neither. Look into the ''cover'', ''contain'' and ''100%'' values for this attribute.


这篇关于html中div元素的图像背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆