CSS 文本重叠。Z 索引不起作用



我在一个带有背景图像的表中有一个多级菜单。我遇到的问题是,当新级别菜单显示的文本相互重叠时。我试着用z索引级别来做,但对我不起作用。

图片示例:https://i.ibb.co/ZK1TnJv/Sin-t-tulo-1.png

代码:

<html>
<head>
</head>
<body>
<style>
.third-level-menu
{
position: absolute;
top: 0;
right: -120px;
width: 178px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menux2     /* Variation of third level with different position */
{
position: absolute;
top: 0;
right: -140px;
width: 178px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu > li
{
height: 40px;
background: #c39cad;
}
.third-level-menux2 > li
{
height: 40px;
background: #c39cad;
}
.third-level-menu > li:hover { background: #8e5e73; }
.third-level-menux2 > li:hover { background: #8e5e73; }
.second-level-menu
{
position: absolute;
top: 30px;
left: 0;
width: 178px;
list-style: none;
padding: 3;
margin: 0;
display: none;
}
.second-level-menu > li
{
position: relative;
	top: 10px;
height: 32px;
background: #c39cad;
}
.second-level-menu > li:hover { background: #8e5e73; }
.top-level-menu
{
list-style: none;
padding: 0;
margin: 0;
}
.top-level-menu > li
{
position: relative;
float: left;
height: 30px;
width: 120px;
background: #d3b0bc9;
}
.top-level-menu > li:hover { background: #d3b0bc9;  }
.top-level-menu li:hover > ul
{
/* On hover, display the next level's menu */
display: inline;
	
}
/* Menu Link Styles */
.top-level-menu a /* Apply to all links inside the multi-level menu */
{
font: bold 13px Arial, Helvetica, sans-serif;
color: #ffffff;
text-decoration: none;
padding: 0 0 0 10px;
	

/* Make the link cover the entire list item-container */
display: block;
line-height: 18px;
}
.top-level-menu a:hover { color: #ffffff; 
</style>
<body>
<table background="https://i.ibb.co/KNpk9Md/demo.jpg" width="917" border="0">
<tr>
<td width="103" height="244" rowspan="7">      
<td width="117" rowspan="3">    
<td width="81" rowspan="7">    
<td width="123" height="21">    
<td width="75" rowspan="7">    
<td width="128" rowspan="2">    
<td width="65" rowspan="7">    
<td width="128" rowspan="2">    
<td width="59" rowspan="7">      </tr>
<tr>
<td height="32"><ul class="top-level-menu">
<li>
<a href="#">PE02 Plan gestión</a>
<ul class="third-level-menux2">
<li><a href="#">Procedimiento</a></li>

</ul>
</li>
</ul>
</li>
</ul>    
</tr>
<tr>
<td>        
<td width="128">5          
<td width="128">7      
</tr>
<tr>
<td width="117"><ul class="top-level-menu">
<li>
<a href="#">OPE01 Plan estratégico</a>
<ul class="second-level-menu">
<li><a href="#">Procedimiento</a></li>
<li>
<a href="#">REGISTROS</a>
<ul class="third-level-menu">
<li><a href="#">Seguimiento y Evaluación</a></li>

</ul>
</li>
</ul>
</li>
</ul>        
<td height="43"><ul class="top-level-menu">
<li>
<a href="#">PE03 Inversiones y nuevos proy.</a>
<ul class="second-level-menu">
<li><a href="#">Procedimiento</a></li>
<li><a href="#">Instrucción Responsable</a></li>
<li>
<a href="#">REGISTROS</a>
<ul class="third-level-menu">
<li><a href="#">Metáfora Empresa</a></li>
<li><a href="#">Planificación Proyecto</a>			 
<li><a href="#">Requisitos Proyecto</a></li>
</ul>
</li>
</ul>
</li>
</ul>        
<td width="128">          
<td width="128">      </tr>
<tr>
<td width="117">    
<td height="21">        
<td width="128">6          
<td width="128">8      
</tr>
<tr>
<td width="117">    
<td height="38"><ul class="top-level-menu">
<li>
<a href="#">PE04 Responsab. social</a>
<ul class="second-level-menu">
<li><a href="#1">Procedimiento</a></li>
<li><a href="#">REGISTROS</a></li>
<ul class="third-level-menu">
<li><a href="#">Cumplimiento Comunicaciones GI</a></li>
<li><a href="#">Temas y Canales GI</a></li>
</ul>

</ul>
</li>
</ul>   

<td width="128">          
<td width="128">      </tr>
<tr>
<td width="117">    
<td height="23">        
<td width="128">          
<td width="128">      </tr>
</table>
</body></html>

i为.second-level-menu添加了z-index:5

<html>
<head>
</head>
<body>
<style>
.third-level-menu
{
position: absolute;
top: 0;
right: -120px;
width: 178px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menux2     /* Variation of third level with different position */
{
position: absolute;
top: 0;
right: -140px;
width: 178px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu > li
{
height: 40px;
background: #c39cad;
}
.third-level-menux2 > li
{
height: 40px;
background: #c39cad;
}
.third-level-menu > li:hover { background: #8e5e73; }
.third-level-menux2 > li:hover { background: #8e5e73; }
.second-level-menu
{
position: absolute;
top: 30px;
left: 0;
width: 178px;
list-style: none;
padding: 3;
margin: 0;
display: none;
z-index:5;
}
.second-level-menu > li
{
position: relative;
	top: 10px;
height: 32px;
background: #c39cad;
}
.second-level-menu > li:hover { background: #8e5e73; }
.top-level-menu
{
list-style: none;
padding: 0;
margin: 0;
}
.top-level-menu > li
{
position: relative;
float: left;
height: 30px;
width: 120px;
background: #d3b0bc9;
}
.top-level-menu > li:hover { background: #d3b0bc9;  }
.top-level-menu li:hover > ul
{
/* On hover, display the next level's menu */
display: inline;
	
}
/* Menu Link Styles */
.top-level-menu a /* Apply to all links inside the multi-level menu */
{
font: bold 13px Arial, Helvetica, sans-serif;
color: #ffffff;
text-decoration: none;
padding: 0 0 0 10px;
	

/* Make the link cover the entire list item-container */
display: block;
line-height: 18px;
}
.top-level-menu a:hover { color: #ffffff; 
</style>
<body>
<table background="https://i.ibb.co/KNpk9Md/demo.jpg" width="917" border="0">
<tr>
<td width="103" height="244" rowspan="7">      
<td width="117" rowspan="3">    
<td width="81" rowspan="7">    
<td width="123" height="21">    
<td width="75" rowspan="7">    
<td width="128" rowspan="2">    
<td width="65" rowspan="7">    
<td width="128" rowspan="2">    
<td width="59" rowspan="7">      </tr>
<tr>
<td height="32"><ul class="top-level-menu">
<li>
<a href="#">PE02 Plan gestión</a>
<ul class="third-level-menux2">
<li><a href="#">Procedimiento</a></li>

</ul>
</li>
</ul>
</li>
</ul>    
</tr>
<tr>
<td>        
<td width="128">5          
<td width="128">7      
</tr>
<tr>
<td width="117"><ul class="top-level-menu">
<li>
<a href="#">OPE01 Plan estratégico</a>
<ul class="second-level-menu">
<li><a href="#">Procedimiento</a></li>
<li>
<a href="#">REGISTROS</a>
<ul class="third-level-menu">
<li><a href="#">Seguimiento y Evaluación</a></li>

</ul>
</li>
</ul>
</li>
</ul>        
<td height="43"><ul class="top-level-menu">
<li>
<a href="#">PE03 Inversiones y nuevos proy.</a>
<ul class="second-level-menu">
<li><a href="#">Procedimiento</a></li>
<li><a href="#">Instrucción Responsable</a></li>
<li>
<a href="#">REGISTROS</a>
<ul class="third-level-menu">
<li><a href="#">Metáfora Empresa</a></li>
<li><a href="#">Planificación Proyecto</a>			 
<li><a href="#">Requisitos Proyecto</a></li>
</ul>
</li>
</ul>
</li>
</ul>        
<td width="128">          
<td width="128">      </tr>
<tr>
<td width="117">    
<td height="21">        
<td width="128">6          
<td width="128">8      
</tr>
<tr>
<td width="117">    
<td height="38"><ul class="top-level-menu">
<li>
<a href="#">PE04 Responsab. social</a>
<ul class="second-level-menu">
<li><a href="#1">Procedimiento</a></li>
<li><a href="#">REGISTROS</a></li>
<ul class="third-level-menu">
<li><a href="#">Cumplimiento Comunicaciones GI</a></li>
<li><a href="#">Temas y Canales GI</a></li>
</ul>

</ul>
</li>
</ul>   

<td width="128">          
<td width="128">      </tr>
<tr>
<td width="117">    
<td height="23">        
<td width="128">          
<td width="128">      </tr>
</table>
</body></html>

.second-level-menu{z-index: 5;}

你能在.second-level-menuCSS代码中添加z-index: 5;吗。希望这对你有帮助。

相关内容

  • 没有找到相关文章

最新更新