我想显示从容器中溢出的绝对div。
以下是我的要求:
以下是我遇到的问题:
CSS
#panel {
position: fixed;
top: 0px;
right: 20%;
bottom: 0px;
background: snow;
}
.contact {
background: skyblue;
position: relative;
height:50px;
}
.std {
width: 80px;
}
.vtl {
position: absolute;
background: red;
display: none;
left:-153px;
margin-top:-35px;
width: 150px;
height: 50px;
}
.vtl:after {
content: ' ';
height: 0;
position: absolute;
width: 0;
border: 10px solid transparent;
border-left-color: red;
left: 100%;
top: 10px;
}
.contact:hover .vtl {
display: block;
}
HTML
<div id="panel">
<div class="contact">
<div class="std">
Hover me!
</div>
<div class="vtl">
tools
</div>
</div>
<div class="contact">
<div class="std">
Hover me!
</div>
<div class="vtl">
tools
</div>
</div>
<div class="contact">
<div class="std">
Hover me!
</div>
<div class="vtl">
tools
</div>
</div>
......
</div>
答案 0 :(得分:0)
由于<div class="std">
包含在具有固定位置的<div id="panel">
中,因此您需要扩展#panel
的宽度才能显示<div class="std">
中的内容。例如:
HTML
<div id="panel">
<div class="contact">
<div class="std">
Hover me!
</div>
<div class="vtl">
tools
</div>
</div>
</div>
CSS
#panel {
position: fixed;
top: 0px;
right: 20%;
bottom: 0px;
background: snow;
width:260px;
overflow: auto;
}
.contact {
background: skyblue;
position: relative;
height:50px;
}
.std {
width: 80px;
float:right;
}
.vtl {
position: absolute;
background: red;
display: none;
width: 150px;
margin-left:10px;
margin-top:-10px;
height: 50px;
}
.vtl:after {
content: ' ';
height: 0;
position: absolute;
width: 0;
border: 10px solid transparent;
border-left-color: red;
left: 100%;
top: 10px;
}
.contact:hover .vtl {
display: block;
}
以下是一个有效的例子:http://jsfiddle.net/pZQrA/
答案 1 :(得分:0)
我希望这会有所帮助。对于id面板,放置绝对位置。
#panel {
position: absolute;
top: 0px;
right: 20%;
bottom: 0px;
background: snow;
}