背景图像 - 独立调整高度和宽度
我想要一个带有CSS指定背景图像的div,并且我希望背景图像以一定的偏移量出现。我已经知道如何做那部分了。我还希望能够为 div 设置任意大小,并相应地重新缩放图像。这就是我遇到麻烦的部分。我知道 background-size CSS属性,但这并没有给我任何独立控制 X 轴和 Y 轴的方法。
这可能吗?我只需要支持最新版本的 WebKit。
I want to have a div with a background image specified in CSS, and I want the background image to appear at a certain offset. I already know how to do that part. I also want to be able to set an arbitrary size for the div, and for the image to be rescaled accordingly. That's the part I'm having trouble with. I know about the background-size CSS attribute, but that doesn't give me any way to have independent control over the X and Y axes.
Is this even possible? I only need to support recent versions of WebKit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的错误 - 我链接到的文档似乎已过时。事实上,
background-size
确实允许独立指定高度和宽度,如下所示:My mistake - the document that I linked to seems to be outdated.
background-size
does, in fact, allow for specifying the height and width independently, like this: