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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:34:10+00:00 2026-05-13T09:34:10+00:00

ANY DOM element can be made resizable according to this page: http://jqueryui.com/demos/resizable/ However, it

  • 0

ANY DOM element can be made resizable according to this page: http://jqueryui.com/demos/resizable/

However, it seems that this doesn’t work for the CANVAS element. Possible?

  • 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-13T09:34:10+00:00Added an answer on May 13, 2026 at 9:34 am

    Canvas has two types of resize behavior:

    • Resizing where the contents are stretched to fit the canvas’s new dimensions
    • Resizing where the contents remain static while the canvas grows or shrinks

    Here’s a page that demonstrates the two types of “resizing”: http://xavi.co/static/so-resizable-canvas.html

    If you want the first type of resizing (stretch the content) then place the canvas into a container div and set the width and height of the canvas to 100% using CSS. Here’s what that code might look like:

    /* The CSS */
    #stretch {
        height: 100px;
        width: 200px;
    }
    
    #stretch canvas {
        width: 100%;
        height: 100%;
    }
    
    <!-- The markup -->
    <div id="stretch"><canvas></canvas></div>
    
    // The JavaScript
    $("#stretch").resizable();
    

    The second type of resizing (static content) is a two step process. First you must adjust the width and height attributes of the canvas element. Unfortunately, doing this clears the canvas, so you must then re-draw all its contents. Here’s bit of code that does this:

    /* The CSS */
    #resize {
        height: 100px;
        width: 200px;
    }
    
    <!-- The markup -->
    <div id="resize"><canvas></canvas></div>
    
    // The JavaScript
    $("#resize").resizable({ stop: function(event, ui) {
        $("canvas", this).each(function() { 
            $(this).attr({ width: ui.size.width, height: ui.size.height });
    
            // Adjusting the width or height attribute clears the canvas of
            // its contents, so you are forced to redraw.
            reDraw(this);
        });
    } });
    

    Currently the code above re-draws the canvas’s content when the user stops resizing the widget. It’s possible to re-draw the canvas on resize, however resize events occur fairly often and re-draws are expensive operations — approach with caution.

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

Sidebar

Related Questions

I am using XML minidom (xml.dom.minidom) in Python, but any error in the XML
I am looking for a simple JavaScript example that updates DOM. Any suggestions?
Any personal experience in overcoming web application performance hurdles? Any recommended strategies for improving
Any good recommendations for a platform agnostic (i.e. Javascript) grid control/plugin that will accept
Any good suggestions? Input will be the name of a header file and output
Any ideas on how to implement tab completion for a .NET (C#) Console Application?
any idea how if the following is possible in PHP as a single line
Any suggestions on the best way to ensure thread safety when changing the properties
Any ideas what the average user's download speed is? I'm working on a site
Any suggestions? Using visual studio in C#. Are there any specific tools to use

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.