How to force an image displayed with SVG element to cover the entire width and height

前端 未结 2 2111
忘了有多久
忘了有多久 2021-01-23 01:36

I have generated a blurred image using svg element. I want it to cover the entire width and height of the screen.

Now to better understand I am providing tw

2条回答
  •  星月不相逢
    2021-01-23 01:58

    If you know the dimensions of the image ahead of time, you can use the viewBox and preserveAspectRatio SVG attributes and skip the JavaScript altogether. In my fiddle it appears that you have to specify the image's width and height explicitly as well for this to work.

    
      
        
      
      
    
    

    Another option is to specify the image as the SVG element's background in CSS, blurring with the filter property.

提交回复
热议问题