Created
February 11, 2021 19:55
-
-
Save imagebox/6f7da655d55fc5550eece9469e5b7c15 to your computer and use it in GitHub Desktop.
[Responsive SVG with JS] #svg #responsive #js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// enclose svg in div with class svg-container | |
// in example below, 599/859 is the svg's height/width | |
$(window).on("resize", function () { | |
var myWidth = $('.svg-container').width(); | |
var myHeight = (myWidth * 599/859); | |
$('.svg-container svg').css('width', myWidth + 'px'); | |
$('.svg-container svg').css('height', myHeight + 'px'); | |
}).resize(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment