Skip to content

Instantly share code, notes, and snippets.

@sbruggmann
Created May 30, 2018 15:23
Show Gist options
  • Save sbruggmann/eafc5fd3023e7e62849fa2689870c856 to your computer and use it in GitHub Desktop.
Save sbruggmann/eafc5fd3023e7e62849fa2689870c856 to your computer and use it in GitHub Desktop.
Neos Fusion wrap SVG to make it responsive in IE's
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}
}
.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