English 中文(简体)
让我们把图像放在自己的影射中。
原标题:Let multiple pair of images overlay within their own div
  • 时间:2024-01-18 02:47:30
  •  标签:
  • html
  • css

I am trying to use CSS to let multiple pairs of images overlay within their own div. For example, in the following code, I want img2 over img1, and img4 over img3.

<div class="container">
<img class="base" src="img1.jpg">
<img class="overlay" src="img2.jpg">
</div>

<div class="container">
<img class="base" src="img3.jpg">
<img class="overlay" src="img4.jpg">
</div>

我发现的都是这样的:

.base {
  position: absolute;
}
.overlay {
  position: relative;
}

这四幅图像一带。 任何帮助都值得赞赏!

问题回答

您需要根据您的要求,确定<代码>.container 和.baserelative,并设定z-index。 类似:

.container {
      position: relative;
      display: inline-block;
    }

    .base {
      position: relative;
      z-index: 1;
    }

    .overlay {
      position: absolute;
      top: 0;
      left: 0;
      z-index: 2;
    }




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签