开发者

Stretch an image in a div background

开发者 https://www.devze.com 2023-01-30 16:41 出处:网络
I have a div with a background image - and I want it to stretch as the div itself stretches. My CSS is lik开发者_运维问答e this:

I have a div with a background image - and I want it to stretch as the div itself stretches.

My CSS is lik开发者_运维问答e this:

.infobox-medium-text
{
    width: 473px;
    height: 208px;
    background: url(../../images/infobox/infobox-medium.png) top no-repeat;
    float:left;
}

where as a div receives the .infobox-medium-text class.

Thanks.


Have a look here: Stretch and scale a CSS image in the background - with CSS only

EDIT: If you want this technique to work on a div instead of the body, add position: relative; to the div's css.

0

精彩评论

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

关注公众号