[英]Overlay one image with another without extending parent height
I had a front image on the page, inserted like this: 我在页面上有一张正面图片,像这样插入:
<h1>
<a href...>
<img .../>
</a>
</h1>
Now I want to add another image link, to overlay first one (it is smaller image so it would be Ok): 现在我想添加另一个图像链接,以覆盖第一个(它是较小的图像,所以可以):
<h1>
<a href...>
<img .../>
</a>
<a href... style="position:relative;top:-150px;">
<img ... style="height:150px"/>
</a>
</h1>
It does what I want, but the height of the parent H1
is still enlarged by these 150px
leaving silly empty space. 它可以满足我的要求,但是父级
H1
的高度仍被这150px
扩大,留下了愚蠢的空白空间。
I made height of H1
predefined constant to solve this, however I'm interested in more proper / elegant solution. 我将
H1
高度预定义为常数来解决此问题,但是我对更合适/更优雅的解决方案感兴趣。
First I need to mention if you are using inline styles remove it and add an external style sheet. 首先,我需要提及的是,如果您使用的是内联样式,请将其删除并添加外部样式表。
Below I am giving the answer with inline styles just because you have used them too in your question .Try the following: 在下面,我给出内联样式的答案仅仅是因为您在问题中也使用了它们。请尝试以下操作:
<h1 style="position:relative;">
<a href...>
<img .../>
</a>
<a href... style="position:absolute;top:0;">
<img ... style="height:150px"/>
</a>
</h1>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.