第1个回答 2016-09-03
相对定位和绝对定位,把盒子相对定位,给超链接那个盒子相对定位,不加也行,
给菜单的那个盒子绝对定位,默认是隐藏的也就是display:none,给链接加个伪类hover或者鼠标悬浮事件,onmouseover。具体代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8"/>
<title></title>
<style type="text/css">
ul li{
float: left;
width: 100px;
height: 30px;
line-height: 30px;
text-align: center;
border: 1px solid black;
margin-right: 50px;
}
ul{
list-style: none;
}
div{
width: 120px;
height: 100px;
position: absolute;
border: 1px solid red;
display: none;
}
#d1{
width: 120px;
height: 100px;
position: absolute;
border: 1px solid blue;
display: none;
}
ul li:hover div{
display: block;
}
ul #t:hover div{
display: block;
}
ul #f:hover #d1{
display: block;
}
</style>
</head>
<body>
<ul>
<li id="f">春<div id="d1"></div></li>
<li>夏</li>
<li id="t">秋<div></div></li>
<li>东<div></div></li>
</ul>
</body>
</html>
我没有在div里面写列表,你要写列表直接在div里面加就可以了
第2个回答 2016-07-30
使用div+css就可以实现,使用样式display:block;
块级元素默认就是block,思路是:当页面加载时,一级菜单下的二级菜单display设置为none;鼠标移动时样式设为block就可以实现了。可以参考标准之路网站的10天学会div+css
第八天的内容。
第3个回答 2016-07-12
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
.tankuang {
height: 100px;
width: 100px;
background-color: #000000;
display: none;
}
</style>
</head>
<body>
<script>
function block() {
document.getElementsByClassName("tankuang")[0].style.display = "block";
}
function none() {
document.getElementsByClassName("tankuang")[0].style.display = "none";
}
</script>
<div>
<a href="#" onmousemove="block()" onmouseout="none()">悬浮上来</a>
<div class="tankuang"></div>
</div>
</body>
</html>
第4个回答 2016-08-18
可以使用jQuery很简单就能做出来
$("a").mouseover(function(){
$("div").show();
});
$("a").mouseout(function(){
$("div").hide();
});