我有一个带有3个图像的div容器的网页。图1填充了左侧容器的高度。图像2位于容器的中心,但位于图像1的右侧。图像3位于容器的右下角。我希望图片3始终位于图片1的右侧。有没有一种方法可以使用html/css来实现这一点?目前,如果我调整窗口大小,Image 3会覆盖(或覆盖)Image 1(取决于z-index)。HTML/CSS - 从容器的右侧定位标签,并在另一个标签的右侧
样品插图:
- - - - - - - -
| | |
| | |
| | - - | |
| | - - | |
| | | - - |
| | | - - |
- - - - - - - -
示例代码:
<div background="{some background}" style="width: 100%; height: 750px; position: relative; background: {some background};">
<img src="{some image 1}" style="position: absolute; width: auto; height: 100%; left: 0px; z-index: 1;">
<img src="{some image 2}" style="position: absolute; width: 456px; height: auto; margin: auto; top: 0; left: 432px; bottom: 0; z-index: 2;">
<img src="{some image 3}" style="position: absolute; width: 456px; height: auto; margin: auto; bottom: 25px; right: 25px; z-index: 2;">
</div>
你的image3有一个右边:35像素和绝对位置这将拉动图像到屏幕的右侧,你需要为它分配与图像2相同的左边距以使它们对齐 – 2015-04-01 04:53:16
图像3掩盖因为图像1的宽度是自动的,所有图像位置都是绝对的。 – ketan 2015-04-01 04:53:56
@AwRak,我不想让图像2和3对齐。我希望他们永远在图片1的右侧;他们在容器中的位置是正确的。 – lgdroid57 2015-04-01 05:07:59