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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:31:09+00:00 2026-05-14T22:31:09+00:00

I have a element, containing three overlapping images. Inspecting the element in Chrome shows

  • 0

I have a element, containing three overlapping images. Inspecting the element in Chrome shows this:

<span id=​"span1">​
   <img id=​"img1" src=​"images/​progressbar.gif" width=​"120" style=​"position:​ relative;​ z-index:​ 3;​">​
   <img id=​"img2" src=​"images/​progressbar.gif" style=​"width:​ 120px;​ height:​ 12px;​​ position:​ relative;​ left:​ -120px;​ z-index:​ 2;​">​
   <img id=​"img3" src=​"images/​progressbar.gif" style=​"width:​ 120px;​ height:​ 12px;​ position:​ relative;​ left:​ -240px;​ z-index:​ 1;​">​
</span>​

The important point is that the second two images are given a relative position, shifting them to the left so they perfectly overlap the first. But the span itself is still 360 pixels wide (3 x 120 pixels per image). So how can I achieve this effect while keeping the span width tightly bounded around the images?

Thanks!

  • 1 1 Answer
  • 1 View
  • 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-14T22:31:09+00:00Added an answer on May 14, 2026 at 10:31 pm

    What’s happening here is that the browser’s layout engine performs an initial layout (before taking into account your relative positioning), computes the span‘s width (which is 3x your image width) and then moves the images to where you specify.

    The obvious solution is to also do <span id="span1" style="width:120px;">. I think this is acceptable in your case, as the 120px part (and its multiples) already needs to be specified to achieve the layout.

    Another solution would be to give position: absolute to all images except the first (you will also need to give position: relative to the <span>). This would remove them from the layout and allow your span to snugly wrap around all remaining content (i.e., just one image). In this case though I am not sure how the z-index properties of your images (which have different position) would interact. Probably just fine. 🙂

    Edit: by using the last solution (and assuming there are no z-index problems), you can achieve your desired layout without specifying 120px anywhere. This could be important, so keep it in mind.

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

Sidebar

Related Questions

I have a border element with rounded corners containing a 3x3 grid. The corners
I have a span element inside a table td element. The span tag has
I have an issue with a table containing three cells in one row. Two
I have two arrays containing the same elements, but in different orders, and I
I have an element with an onclick method. I would like to activate that
I have an element that is similar to a tag (because it has word-wrap:
I have an element in my document that has a background color and image
Does the HTML select element have an on select event? what exactly is the
I am trying to have an element fade in, then in 5000 ms fade
I'm trying to use XPath to find all elements that have an element in

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.