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 6101191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:28:19+00:00 2026-05-23T13:28:19+00:00

I have an SVG image which fits its parent <object> dimensions. The image is

  • 0

I have an SVG image which fits its parent <object> dimensions. The image is zoomed by changing its currentScale and currentTranslate properties. How can I scale the image to be shown at its intended size and center it in the viewport?

Example code:

<object width="500" height="300" data="pic.svg">
    <!-- The image will scale to be 300px heigh, 
         I need it to be shown at 32x32 and centered in the viewport,
         but could be zoomed to any size.
         Setting width and height attributes will crop the viewable area to 32x32,
         so we can't use this solution.
     -->
    <svg viewBox="0 0 32 32" ... >
</object>
  • 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-23T13:28:20+00:00Added an answer on May 23, 2026 at 1:28 pm

    Ok, I found the solution. To do this I got the intended size from width/height/viewbox (depending on which is available), made the viewBox equal the size of the available viewport (i.e. the containing <object> tag) and changed the x/y values of the viewBox attribute so that the image appears to be in the center of the viewport, and removed width and height attributes if they were present.

    I use this in my Opera SVG Viewer widget, you can see my SVG zooming library here.

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

Sidebar

Related Questions

I have a JSF 2 application which creates some SVG content. How can i
I have a pixelart-style image which intend to scale to 4x size with SVG.
I have an SVG image of the united states which I've drawn with a
I have made a SVG image, or more like mini application, for viewing graphs
I have a php script (generator.php) which generates certain HTML/XML/SVG depending on various conditions.
Can d3.js layout.force be used to (re)position non-svg elements like div's? If div's have
I have a embedded image in an .org file which I then publish as
In my Android application I have created an SVG image converter class. It parses
I have a UIWebView and I want to load an SVG image into it.
I have some objects inside of svg that can be clicked by user. Is

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.