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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:18:10+00:00 2026-05-11T12:18:10+00:00

I have an image inside a span tag, the span has a set width

  • 0

I have an image inside a span tag, the span has a set width and height, and is set to overflow hidden. so it only reveals a small portion of the image. This works but the small portion of the image that is visible is the top left corner. I would like it to be the center of the image that is visible. I think I need to absolutely position the image, but the size of the image can vary though. Does anyone know how to do what I am trying to do?

Thanks!

Here is the HTML:

<div class='lightbox_images'>                 <h6>Alternate Views</h6>                 <span>                     <a href='http://www.kranichs.com/mothers_rings/mothers_rings_txt2.jpg' rel='lightbox[product_alternate_views]' title='This is my captions 1'>                         <img src='http://www.kranichs.com/mothers_rings/mothers_rings_txt2.jpg' />                     </a>                 </span>                 <span>                     <a href='https://www.kranichs.com/product_images/Simon-G@346_M_346_M.jpg' rel='lightbox[product_alternate_views]' title='This is my captions 2'>                         <img src='https://www.kranichs.com/product_images/Simon-G@346_M_346_M.jpg' />                     </a>                 </span>                 <span>                     <a href='http://www.kranichs.com/images/simong/sim_banner_01.jpg' rel='lightbox[product_alternate_views]' title='This is my captions 3'>                         <img src='http://www.kranichs.com/images/simong/sim_banner_01.jpg' />                     </a>                 </span>                 <span>                     <a href='http://www.kranichs.com/images/psu/psu_banner.jpg' rel='lightbox[product_alternate_views]' title='This is my captions 4'>                         <img src='http://www.kranichs.com/images/psu/psu_banner.jpg' />                     </a>                 </span>             </div> 

Here is the CSS:

.lightbox_images{     background-color:#F9F9F9;     border:1px solid #F0F0F0; } .lightbox_images h6{     font-family:Verdana, Arial, Helvetica, sans-serif;     color:#333333;     font-size:14px;     font-weight:bold;     font-style:italic;     text-decoration:none;     margin:0px; } .lightbox_images span{     padding:5px;     padding-bottom:15px;     background-color:#DFDFDF;     margin:5px;     display:inline-block;     border:1px solid #CCC; } .lightbox_images a{     display:inline-block;     width:60px;     height:60px;     overflow:hidden;     position:relative; }  .lightbox_images a img{     position:absolute;     left:-50%;     top:-50%; }  .lightbox_images span:hover{     border:1px solid #BBB;     background-color:#CFCFCF; } 
  • 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. 2026-05-11T12:18:10+00:00Added an answer on May 11, 2026 at 12:18 pm

    Given this sort of HTML:

    <span><img src='...' width='...' height='...' alt='...' /></span> 

    You could use CSS like this:

    span {   position: relative;   display: block;   width: 50px;  /* Change this */   height: 50px; /* Change this */   overflow: hidden;   border: 1px solid #000; } span img {   position: absolute;   left: -10px; /* Change this */   top: -10px;  /* Change this */ } 

    You can then center the image based on its exact dimensions.

    Alternatively, if you’re able to modify the HTML, you could instead use something like this:

    <div>   <a href='...'>[name of picture]</a> </div> 

    Then, match it with this CSS:

    div {   width: 50px;   height: 50px;   background: transparent url(...) center center no-repeat;   border: 1px solid #000; } div a {   display: block;   height: 100%;   text-indent: -9999em; /* Hides the link text */ } 

    In this case, the background will be automatically centered regardless of its dimensions, and it’ll still be clickable.

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

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Npgsql is a .NET provider for PostgreSQL. Whether or not… May 11, 2026 at 11:33 pm
  • Editorial Team
    Editorial Team added an answer To answer my own question, after posting on openssl mailing… May 11, 2026 at 11:33 pm
  • Editorial Team
    Editorial Team added an answer Basically, clone is broken. Nothing will work with generics easily.… May 11, 2026 at 11:33 pm

Related Questions

I have an element in my document that has a background color and image
I need a solution where a user could enter the URL of a web
I have an application that displays an image inside of a Windows Forms PictureBox
HI, Is there a way by which I can rotate an image inside a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.