简体   繁体   English

在相对容器中定位绝对div

[英]Positioning absolute div inside relative container

I have an image and want to show a rollover popup div on hover of that image. 我有一张图片,想要在该图片的悬停上显示一个鼠标悬停弹出式div。 Below is my code; 下面是我的代码;

<div class="wrapper">
    <ul class="popup">
        <li><a href="#"Link 1</a></li>
                  <li><a href="#"Link 2</a></li>
        <li><a href="#"Link 3</a></li>
                  <li><a href="#"Link 4</a></li>
    </ul>
    <img src="iOpenPopupOnHover.gif" /
</div>
<div class="wrapper">
    <ul class="popup">
        <li><a href="#"Link 1</a></li>
                  <li><a href="#"Link 2</a></li>
        <li><a href="#"Link 3</a></li>
                  <li><a href="#"Link 4</a></li>
    </ul>
    <img src="iOpenPopupOnHover.gif" /
</div>
...

Now I use position:relative for the wrapper and position: absolute for the popup. 现在,我将position:relative用于包装器,并将position:absolute用于弹出式窗口。 This is bcoz I want to position the popup at the top/center with respect to each image.. 这是bcoz,我想将弹出窗口相对于每个图像定位在顶部/中央。

Now the issue is while the absolute position seems to be getting calculated with respect to the image, the popup is completely contained within the wrapper div and kind of crops some of the popup links. 现在的问题是,相对于图像似乎正在计算绝对位置时,弹出窗口完全包含在wrapper div中,并且某些弹出链接属于某种作物。 I want the complete popup to get displayed...How do I fix this? 我希望显示完整的弹出窗口...如何解决此问题?

Below is the CSS 下面是CSS

.wrapper {
    float: left;
    position: relative;
}

.popup {
    display: none;
    width: 80px;
    background-color: red;
    position: absolute;
    bottom: 105px;
    left: 10px;
}

Something like this? 像这样吗

.wrapper {
    float: left;
    position: relative;
    overflow: visible;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM