开发者

fit background image in to a dynamic div

i have a background image (700x500px) and i want to f开发者_StackOverflowill wit it a dynamic div. in this example the div is only 20px but it can have a height over 500px.

<div style="background-image:url('background.jpg');width:710px">
some content some content
</div>


Using standard CSS you can't just fit a background image. But you can use an image tag in a div and make it resize. And then use your content in front of it, so the image will be used as a background.

You can find more details, css usage and an example page here :
http://www.quackit.com/html/codes/html_stretch_background_image.cfm


You can just add background-size: cover; to your style attribute

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜