Scale element proportional to Background Cover with jQuery

前端 未结 6 1696
情话喂你
情话喂你 2020-11-28 10:11

I have a tricky question: I have a fullsize background over the site I\'m working on. Now I want to attach a div to a certain position on the image and also that the div sc

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 10:26

    A far simpler/better approach to you problem is to use an SVG element, it is better suited to your requirement. The cool thing about SVG is everything will scale proportionally by default because it is a vector object not a document flow object.

    This example will demonstrate the technique

    
    
        
            SVG
            
        
        
            
                
                
                
                
            
            
        
    
    

    You can add images to SVG to achieve what you need.

    https://jsfiddle.net/tnt1/3f23amue/

提交回复
热议问题