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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:57:57+00:00 2026-05-23T22:57:57+00:00

I am using a div whose dimensions are set using jquery, but i wish

  • 0

I am using a div whose dimensions are set using jquery, but i wish to show an image in that div and i also want the image to resize accordingly to fit in the div exactly.

How can this be done ???

  • 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-23T22:57:58+00:00Added an answer on May 23, 2026 at 10:57 pm

    If you are using jQuery to handle the parameters of a DIV element, then you could use the same method to handle the height/width of the image. You could try something like:

    var MyImg = document.getElementById(img_id);
    var Div = document.getElementById(div_id);
    document.MyImg.style.height = document.Div.style.height;
    document.MyImg.style.width = document.Div.style.width;
    

    If you want to leave a small border, subtract a few pixels from both the height and the width and align the image centrally both horizontally and vertically.

    Addon: Alternatively, you couls set CSS attributes to:
    height: auto;
    width: auto;

    I had understood you wanted to use jQuery, my bad…

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

Sidebar

Related Questions

I have a funciton that I am currently using to show a hidden div.a_type
I am using jQuery's $.get() to load some content to a div whose id=results
I am using a jQuery plugin that has an event handler whose return function
I'm using YUI to add drag drop support to a div. It also responds
I have a simple html page with a div. I am using jQuery to
Most people are aware of Using absolute positioning on a div whose parent is
I have a div whose contents I want to update by AJAX. To make
(Note: I'm using jQuery below, but the question is really a general JavaScript one.)
I have a table whose body I've made sortable using jQuery UI's Sortable function.
I am using jQuery to load a new page inside the div example-placeholder <script>

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.