Search code examples
google-chromesvgwebkit

Chrome messes up SVG files' height while loading pages


I'm working with custom SVG files, embedded in <object> tags. It renders properly but for some reason, I experience a weird bug on Chrome browser.

On page load, the Chrome seems to "calculate" the height of my elements and displays a wrong height for the wrapping elements. IE and FF behave normally though.

enter image description here


Solution

  • Anyways, I use an ugly fix. By default, my <object> has height:0 CSS property, then I apply the following script (CoffeeScript syntax):

    $(document).ready ->
      $('object').each ->
        $(this).load ->
          $(this).css('height', 'auto')
    

    It makes the job...