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

  • Home
  • SEARCH
  • 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 5950301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:22:27+00:00 2026-05-22T17:22:27+00:00

I am using jQuery plugin for resizing the elements. Elements height & width is

  • 0

I am using jQuery plugin for resizing the elements. Elements height & width is set in percentage (%) not in pixel. Whenever i re-size any element it’s height & width changes to pixels which is fixed but i wanted this change in percentage.

I am sure there must be some technical issue for this but there would be solution too.

#parentDiv { height:100%; width:100%;}

.image { height: 25%; width: 25%; }  

<body>
<div id = "parentDiv">
    <div class="image" id="image1" onmouseover="resizeMe(this);"> </div>
    <div class="image" id="image2" onmouseover="resizeMe(this);"> </div>
</div>  

<script> 
  function resizeMe(obj) {
        $(#obj.id).resizable();  }

</body>

But once i re-size id=image1, below is HTML code. it contains the height & width size in pixels. Does anybody light on it, How can i manage to re-size in percentage only.

<div class="image" style="width: 345px; height: 52px;">
  • 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-22T17:22:28+00:00Added an answer on May 22, 2026 at 5:22 pm

    jQuery gets its values from the browsers DOM engine, which always return normalized values in pixels no matter how they were intially set.

    So the only way you will be able to do this is by recalculating the percentages based on elements width/height and parents width/height once the resizing has stopped.

    $(".image").resizable({
        autoHide: true,
        stop: function(e, ui) {
            var parent = ui.element.parent();
            ui.element.css({
                width: ui.element.width()/parent.width()*100+"%",
                height: ui.element.height()/parent.height()*100+"%"
            });
        }
    });
    

    See the above in action on jsFiddle

    Notice how I’m setting the width/height with .css instead of using .width and .height. This is because the latter will be normalized by the DOM engine and turned into pixels.

    Now to some feedback on your code. It’s quite a mess to be honest. It’s a really bad practice to use inline styling and scripts. Set the width/height of #parentDiv with css just as you did with .image. And don’t use onmouseover attribute. Instead bind the event with jQuery using .bind.

    Also you shouldn’t make the elements resizable on mouse over. It should be done once, when the document is ready. Use the autoHide option to hide the handlers while the mouse isn’t over the element. An alternative is to bind enable and disable methods to mouse hover, but that will not have the same result.

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

Sidebar

Related Questions

I was using Jquery Numeric plugin but I found that is not working on
I'm using Jquery plugin DropShadow: web site And I want to set drop shadow
Is there any jquery plugin similar to Whatever:hover http://www.xs4all.nl/~peterned/csshover.html ?.I'm using jquery library already
am using jquery tablesorter plugin and in my country column i got special characters
I am using the jquery validation plugin from: http://bassistance.de/jquery-plugins/jquery-plugin-validation/ How can I add a
I am using the jQuery plugin to add support for SwfUpload by steven sanderson
I am using jquery lightbox plugin colorbox ( http://colorpowered.com/colorbox/ ) and i want to
I am using jquery validation plugin for form validation. I have added a custom
I am using Jquery Cycle Plugin and it has a side panel that highlights
I'm using jQuery autocomplete plugin from jQuery website calling the controller url which return

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.