简体   繁体   English

如何将图像拉伸到 VH 和/或 VW(实际上是拉伸)

[英]How to make an image stretch to VH and/or VW (actually stretch)

Basically I have a decorative background image which I want to constantly stretch to the background of the site.基本上我有一个装饰性的背景图像,我想不断地延伸到网站的背景。 No cropping or care given to aspect ratio.没有裁剪或注意纵横比。 Is there a custom velo code for this?是否有自定义的 velo 代码?

Hoping for a plug and play solution.希望有一个即插即用的解决方案。 Will buy coffee.会买咖啡。


Full page background in 2 lines of css.整页背景 2 行 css。

 body { background-image: url("https://149351115.v2.pressablecdn.com/wp-content/uploads/2017/12/SO_Announcement-1200x675.png"); background-size: cover; }


If you want it to stretch so, whole image can is visible, then:如果你想让它拉伸,整个图像都可以看到,那么:

 body { background-image: url("https://149351115.v2.pressablecdn.com/wp-content/uploads/2017/12/SO_Announcement-1200x675.png"); background-size: 100% 100vh; }

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

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