Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7496119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:29:32+00:00 2026-05-29T18:29:32+00:00

If I have inline SVG, including an element which has been scaled… <g transform=scale(sX,sY)>

  • 0

If I have inline SVG, including an element which has been scaled…

<g transform="scale(sX,sY)">
    <rect id="myElement" x="107" y="32" width="245" height="31" stroke="#C6C3C6" stroke-width="1px" />
</g>

… or which is in a <svg> element with a viewBox attribute:

<svg viewBox="20 20 5000 1230">
    <g transform="scale(sX,sY)">
        <rect id="myElement" x="107" y="32" width="245" height="31" stroke="#C6C3C6" stroke-width="1px" />
    </g>
<svg>

… how can I programmatically find the new scaled width in pixels of myElement – without manually detecting the scaling and doing the math? So far myElement.getBBox().width returns 245 without accounting for the scaling.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:29:34+00:00Added an answer on May 29, 2026 at 6:29 pm

    please check this fiddle http://jsfiddle.net/T723E/. Click on the rectangles and note the firebug console.
    Here i have hard coded a number .3 which is 300px width of div containing svg node / 1000 user units.

    After seeing the bounty, this is the function i have return to get the scaled width without much (with no maths i’m not sure.)maths.Use matrix.d for getting scaled height

        var svg = document.getElementById('svg'); 
        function getTransformedWidth(el){
            var matrix = el.getTransformToElement(svg);
            return matrix.a*el.width.animVal.value;
        }
    
        var ele = document.getElementById('myElement_with_scale')
        console.log("scale width----", getTransformedWidth(ele))
    

    Please look this fiddle for complete code http://jsfiddle.net/b4KXr/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an inline svg with foreignObject elements which contain xhtml fragments. however, the
I have an inline formset for a model, which has a unique_together constraint. And
Background: I need to have an inline element to which I can apply width
I have been dealing with Nasm and GNU C inline asm on a Linux
I have an inline SVG with in an HTML5 document, and would like to
I currently have problems aligning inline SVG correctly inside a bounding DIV, like in
I have a stand-alone svg file that displays without problems. It includes some inline
I have an inline jquery ui datepicker that has some days disabled, like this
I've been working with an HTML5 document with inline SVG and javascript animation. I'd
I have an inline SVG code inside a HTML page, <body> <div style=width:1000px;height:1000px> <svg

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.