我使用hover
在css
表数据上显示了动态生成的弹出窗口。
弹出窗口position
为fixed
或absolute
时效果正常,但如果position
设为relative
则表格数据高度会增加。
以下是使用的HTML和CSS:
CSS
.dropv, .dropv ul {
padding: 0;
margin: 0;
list-style: none;
}
.dropv a {
display:inline;
width: 185px;
}
.dropv li {
float: left;
padding: 0px 8px 2px 0px;
}
/* all list items */
.dropv li ul {
position: fixed;
background-color: lightyellow;
padding: 0px 0px 0px 4px;
width: 185px;
left: -9999px;
}
/* second-level lists */
.dropv li:hover ul {
left: auto;
}
/* nest list under hovered list items */
.dropv li ul li a {
color: blue;
text-decoration: none;
display: block;
}
.dropv li ul li a:hover {
position: relative;
text-decoration: underline;
}
HTML
<td id="' + frameoperationtooltip.concat(framecol) + '" style="display:table-row;">
<div class="dataheight">
<ul class="dropv">
<li>' + operation + '<ul><li>Message Recieved(Bytes):' + writtenBytes + '</li>
<li>No. Of Streams:' + readBytes + '</li>
<li>Message Sent(Bytes):' + nbStreams + '</li>
<li>Size of Streams(Bytes):' + sizeOfStreams + '</li>
<li>Elapsed Time(ms):' + elapsedTime + '</li>
<li><a href="javascript:OpenFileInPopup("' + request + '","' + preframerow + '");">Request</a>
<li><a href="javascript:OpenFileInPopup("' + response + '","' + preframerow + '");">Response</a>
<li><a href="javascript:OpenFileInPopup("' + callStack + '","' + preframerow + '");">CallStack</a>
</li></ul></li>
</ul>
</div>
</td>
fixed
position
的问题在于我的表有很多行,而对于需要向下滚动的行,弹出窗口会超出页面而对于relative
,它会增加行高。
答案 0 :(得分:0)
试试这个
table {
table-layout: fixed;
}
答案 1 :(得分:0)
如果你想在屏幕中央放置一些东西(同样在滚动时):
.dropv {
position: fixed;
background-color: lightyellow;
width: 50px;
height:50px;
bottom:0;
top:0;
left:0;
right:0;
margin:auto;
}
(您的固定元素已离开-99999?)