我需要在他的父 div (table-list-div 始终可见) 上方显示一个隐藏菜单 (dropdown-menu dropdown-menu-right)。
当我点击按钮时,只显示一半菜单,另一半隐藏在父 div 中。
我如何显示所有菜单 wixh 是一个需要显示在其父 div 上方的 div。
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<style>
.table-list-div {
position: relative;
z-index: 1;
border:1px solid blue;
}
.table-list-results {
position: relative;
z-index: 20;
}
.paging {
position: relative;
background:#f6f6f6;
position: relative;
z-index: 10;
}
.dropdown-menu-right
{
border:15px solid orange;
position: relative;
z-index: 500;
}
</style>
</head>
<body>
<div class="table-list-div always-visible">
<table class="table-list-results">
<tr>
<td class="actions">
<div class="btn-group">
<button type="button" class="btn btn-xs dropdown-toggle" data-toggle="dropdown">More</button>
<ul class="dropdown-menu dropdown-menu-right" >
<li ><a href="/action/abc/def">see</a></li>
<li ><a href="/action/ghi">cancel</a></li>
</ul>
</div>
</td>
</tr>
</table>
<br>
<br>
<br>
</div>
<div class="paging paging-bottom center"></div>
</body>
最佳答案
好的,如果我理解您的问题,您需要通过单击操纵 z-index 的可见部分来显示隐藏菜单。
要在 javascript 中执行此操作,您可以使用 z-index 操作
var elem = document.getElementById('yourid');
elem.style.zIndex = 0;
您可以将 onclick 事件触发到调用类似于我上面的目的的函数。
关于html - 使用 z-index 在另一个 div 上方显示 onclick 隐藏的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37575541/