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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:48:14+00:00 2026-06-17T05:48:14+00:00

I have a large number of variable size images that may either be uploaded

  • 0

I have a large number of variable size images that may either be uploaded or found in a database. Without running a script to do the resizing, is there any way to purely modify the HTML or use CSS so that instead of having the image distorted and stretched out to match my allocated dimensions of 300×200, I instead have a 300×200 image cut of out my originally large picture (say for example 400×400)?

My current markup looks like

<image data-src="holder.js/300x200" alt="300x200" style="width:300px; height:200px;" src={{ photo.source_descr }}>
  • 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-06-17T05:48:15+00:00Added an answer on June 17, 2026 at 5:48 am

    If I understood your question correctly, you want to resize the image using CSS/HTML with height and width without stretching the image. You want to crop it instead.

    I’m pretty sure that you’re looking for the clip property in CSS. Mix clip and width and height to crop your image so that it isn’t stretched, yet cropped to fit the desired width and height. Read up more about clip here.


    Here is the extra code you requested for your needs (note that it uses jQuery, so you need that embedded for this to work):

    <style>
    .container     { position: relative; overflow: hidden; }
    .container img { position: absolute; }
    </style>
    
    <div class="container">
        <img src="..."/>
    </div>
    
    <script type="text/javascript">
    $image = $('.container img');
    width = $image.width();
    height = $image.height();
    
    $image.css({
        left: 0 - (width / 2),
        top: 0 - (height / 2)
    });
    </script>
    

    Note that I got the second script from this question: Cropping images from center on the fly.

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

Sidebar

Related Questions

I have a large number of html documents that need a variable number of
I have a large number of records (10,000, increasing every day) that essentially is
I have a large number of documents (mainly PDFs) that I want to index
I have a large number of csv files that look like this below: xxxxxxxx
I have a large number of C# WCF services that are being called by
We have a large number of Python bytearray strings of variable length which need
I have some large ASCII images that I want to check are symmetrical. Say
I have a large number of instances of a C structure like this: struct
We have a large number of programmers on different platforms all using CVS. We
I have a large number of background reads and writes, and a much smaller

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.