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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:40:44+00:00 2026-05-14T15:40:44+00:00

We know how to use CSS to show only part of an image within

  • 0

We know how to use CSS to show only part of an image within a div (i.e., image sprites), but the image has to be a background image.

We know how to use CSS to scale an image, but the image has to be an IMG.

Does anyone know of a way to scale and image and show only part of it?

For example, I want to:

  1. show pixels (15,15) through (100,100), and
  2. scale it up by 200%.

The first I can do by making in a background image. The second I can do by making it a foreground image. But so far, I have not ascertained how to do both. Is it even possible using only CSS/HTML?

  • 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-14T15:40:44+00:00Added an answer on May 14, 2026 at 3:40 pm

    You could scale the image just as you would normally. Then, use a container div to crop the image. To set where the crop rectangle goes, use position: relative on the image (not the containing div). Here’s an example using stackoverflow’s logo:

    <style type="text/css">
    div {
        /* Set size of crop area. Setting its location happens bellow. */
        width: 150;
        height: 100;
        overflow: hidden;  /* Crop it like it's hot! */
    
        /* not part of the implementation; only to display what's going on */
        border: 1px solid black;
        background-color: #ddd;
    }
    
    img {
        /* Set the crop location by shifting the image
         * up by 70px and to the right by 30px.
         */
        position: relative;
        top: -70px;
        left: 30px;
    
        /* Scale the image as you normally would. */
        width: 300px;
        height: 150px;
    }
    </style>
    
    <div>
      <img src="http://sstatic.net/so/img/logo.png">
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You know when you use the CSS background-position property for rollovers, right? Roll over
I know and use eric meyer CSS reset, but is there any more things
It has been suggested that I use CSS for displaying XML. I know in
I am trying to use css to have a background image with opaque attributes
I know it is possible to use jQuery to do something like: $('body').css('cursor','wait'); What
I know you use the C based networking API to do FTP communication but
Now i know to use the method of float.Parse but have bumped into a
so far i only know to use Ctrl-Shift-A to do SVN in TextMate. is
I have a CSS layout in which a content div has absolute positioning to
Somebody know how use OpenX (php app) with Django? I need to use OpenX

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.