开发者

fit background image in to a dynamic div

开发者 https://www.devze.com 2023-01-25 05:18 出处:网络
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.

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

精彩评论

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