Created
May 30, 2018 15:23
-
-
Save sbruggmann/eafc5fd3023e7e62849fa2689870c856 to your computer and use it in GitHub Desktop.
Neos Fusion wrap SVG to make it responsive in IE's
This file contains 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
prototype(Vendor.Package:WrapSvg) < prototype(Fusion:Tag) { | |
sizes = ${String.pregMatch(value, '/viewBox="(\d+) (\d+) (\d+) (\d+)"/i')} | |
width = ${this.sizes[3] - this.sizes[1]} | |
height = ${this.sizes[4] - this.sizes[2]} | |
ratio = ${this.height / this.width * 100} | |
@context.ratio = ${this.ratio} | |
tagName = 'div' | |
attributes { | |
class = 'svg-wrap' | |
style = ${'padding-bottom: ' + ratio + '%;'} | |
} | |
content = ${value} | |
} |
This file contains 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
.svg-wrap { | |
width: 100%; | |
position: relative; | |
display: inline-block; | |
vertical-align: middle; | |
overflow: hidden; | |
svg { | |
position: absolute; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment