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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:11:24+00:00 2026-05-28T03:11:24+00:00

I need to fit an image inside a 300×300 div without stretching the image.

  • 0

I need to fit an image inside a 300×300 div without stretching the image. I’ve seen this on the huff post, the slider on this page :

http://www.huffingtonpost.com/2012/01/07/katy-perry-divorce_n_1191806.html

The images are clipped but not stretched.
Instead of using max-width, max-height.

How do I do this?

  • 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-28T03:11:25+00:00Added an answer on May 28, 2026 at 3:11 am

    Those images on the site you linked to are actual size, so the simple answer is just to resize the image.

    You can’t really do this without “stretching” the image if the image happens to be less than 300px wide or tall, but you can do it without changing the ratio, which is what I think you mean.

    Here’s the basic idea:

    <div><img></div>
    

    If you want to use 300px as a minimum width (you expect small images that need to be bigger), try this:

    div {
        width:300px;
        height:300px;    
        overflow:hidden;
    }
    div img {
        min-width:100%;
    }
    

    Demo: http://jsfiddle.net/Z47JT/

    If you want to clip images (because you expect them to be big) but not enlarge them, try this:

    div {
        width:300px;
        height:300px;    
        overflow:hidden;
        position:relative;
    }
    div img {
        position:absolute;
    }
    

    Demo: http://jsfiddle.net/Z47JT/1/

    Combine both these techniques if you want.

    Another way is to simply use background-image on the container instead, but resizing it (if you want to stretch smaller images) will be difficult unless you use background-size which isn’t fully supported. Otherwise, it’s a great easy solution.

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

Sidebar

Related Questions

I'm trying to make an image stretch to fit inside a div. However I
Need some help to solve this. I have a gridview and inside the gridview
I am loading an image to my silverlight application. This image will fit in
I have a Viewbox with an Image inside of it. This is great since
I am using following configuration to properly fit image inside a scrollview. <?xml version=1.0
I need to place three elements inside RelativeLayout : scaled image in ImageView on
I need to be able to stretch a image background to fit the window
I need to adjust my jqgrid height dynamically to fit in the browser window
What I need is to set the limit of an image's width to 100%
I need to display an image in a resizable dialog (so far all the

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.