简体   繁体   English

如何按比例调整“div”的背景图像大小?

[英]How to proportionally resize the background image of a 'div'?

I need the div idPhoto background image to be scaled proportionally according to the position of the input range .我需要根据input range的位置按比例缩放div idPhoto背景图像。

The code is this: https://jsfiddle.net/fjwpvok5/2/代码是这样的: https : //jsfiddle.net/fjwpvok5/2/

I think that the CSS property background-size is what you're looking for.我认为 CSS 属性background-size就是你要找的。

Depending of what you want, you could use cover , contain or 100% 100% .根据您的需要,您可以使用covercontain100% 100%

https://developer.mozilla.org/en-US/docs/Web/CSS/background-size https://developer.mozilla.org/en-US/docs/Web/CSS/background-size

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM