单击菜单“产品”或将鼠标悬停时,会出现另一个菜单列表。但菜单栏下方的图像块会远离该位置。如果我使用 css [位置:绝对;],则图像框保持静态,并且产品的子菜单与图像块重叠,这就是我想要的。但是图像块的宽度和高度设置会发生巨大变化,从而破坏了对齐方式。请检查 jsFiddle中的编码
.home_menu {
border: 1px solid black;
width: 98%;
height: 3.3%;
margin-right: auto;
margin-left: auto;
}
div#menuDemo {
clear: both;
//border:1px solid black;
height: 78%;
width: 100%;
position: relative;
left: 0;
top: 0;
background-color: #A55927;
/*Remove this next one in production - Used for demo purpose only*/
margin-bottom: 0.1%;
padding-top: 0.7%;
z-index: 4;
}
div#menuDemo ul {
list-style: none;
margin: 0;
padding: 0;
background-color: #A55927;
}
div#menuDemo > ul > li {
float: left;
text-align: center;
}
div#menuDemo ul li {
width: 25%;
//border: 5px solid purple;
}
div#menuDemo ul li a {
text-decoration: none;
font-weight: bolder;
text-align: center;
}
div#menuDemo > ul > li > ul {
display: none;
text-align: center;
}
div#menuDemo > ul > li:hover > ul {
display: block;
text-align: center;
}
.sub1 {
width: 100%;
//border:1px solid green;
}
.colouring {
color: black;
font-weight: bolder;
}
.colour {
//border:1px solid blue;
color: black;
text-align: center;
//width:100%;
}
.wrapper {
border: 5px solid pink;
width: 98.8%;
height: 82%;
margin-top: 1%;
z-index: 2;
}
.uniform_block {
border: 5px solid green;
width: 100%;
height: 40%;
cursor: pointer;
}
.uniform_block img {
width: 100%;
height: 100%;
}
<body>
<div class="home_menu">
<div id="menuDemo">
<ul>
<li id="homeMenu"><a href="#menuHome" class="colour">About Us</a>
</li>
<!-- <li ><a href="#menuHome" class="colour">About Us</a></li> -->
<li><a href="#" class="colour" id="expand">Products</a>
<ul class="sub1">
<li> <a href="#" class="colouring"> Uniforms </a>
<ul>
<li> <a href="#" class="colour">   </a>
</li>
<li> <a href="#" class="colour"> Automobile Industry Uniforms </a>
</li>
<li> <a href="#" class="colour"> Pharmaceutical Uniforms </a>
</li>
<li> <a href="#" class="colour"> Food Industry Uniforms </a>
</li>
<li> <a href="#" class="colour"> Government Sector Uniforms </a>
</li>
<li> <a href="#" class="colour"> School/College Uniforms </a>
</li>
<li> <a href="#" class="colour">   </a>
</li>
</ul>
</li>
<li><a href="#" class="colouring">Shoes</a>
<ul>
<li> <a href="#" class="colour">   </a>
</li>
<li> <a href="#" class="colour"> Industrial Shoes </a>
</li>
<li> <a href="#" class="colour"> Safety & Security Shoes </a>
</li>
<li> <a href="#" class="colour"> Executive Shoes</a>
</li>
<li> <a href="#" class="colour">   </a>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="#" class="colour">Contact Us</a>
</li>
</ul>
</div>
</div>
<div class="wrapper">
<div class="uniform_block">
<img src=" http://t0.gstatic.com/images?q=tbn:ANd9GcSH-kRi3rkVciPcH_c6dDJJI6C1ntzwcKl9MoVQIyuKk8F7unpf" />
</div>
<div class="home_footer">
<div class="footer_contents"></div>
</div>
</div>
</body>
请帮助。我的要求是,当我将鼠标悬停在“产品菜单”上时,应在菜单栏下方的图像块上方查看下拉菜单。