简单美食网站的demo
notice:1.二级菜单需设置绝对定位并将其z-index值加大,母栏设置相对定位
2.轮播图部分设置定时器,通过改变函数来控制图片的原路径
成果展示:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#top {
width: 884px;
height: 500px;
margin: auto;
/*border: 1px solid red;*/
}
#top ul {
padding: 0;
margin: auto;
}
#top ul li {
list-style: none;
}
.f {
float: left;
}
#top ul li a {
text-decoration: none;
display: block;
padding: 4px 10px;
background-color: lightblue;
width: 200px;
height: 50px;
text-align: center;
border-right: 1px solid white;
line-height: 50px;
}
#sub {
display: none;
position: absolute;
z-index: 999;
}
#meum:hover #sub {
display: block;
}
#meum:hover #meum a {
color: yellow;
}
#left {
width: 230px;
height: 440px;
float: left;
margin-top: 10px;
margin-right: 10px;
background-color: burlywood;
border: 1px solid black;
}
.left li {
width: 230px;
height: 80px;
background-color: white;
text-align: center;
line-height: 100px;
border-bottom: 1px solid black;
0 position: relative;
}
#right {
float: right;
margin-top: 10px;
width:630px ;
height:440px ;
/*border: 1px solid yellow;*/
}
#meum {
position: relative;
}
#clear {
clear: both;
}
</style>
<script type="text/javascript">
function init() {
// 定时操作
setInterval("change()", 2000);
}
var i = 0;
function change() {
i++;
document.getElementById("first").src = "picture/" + i + ".jpg";
var j=i+3;
document.getElementById("second").src = "picture/" + j + ".jpg";
if (i == 3) {
i = 0;
}
}
</script>
</head>
<body οnlοad="init()">
<div id="top">
<ul>
<li class="f"><a href="">我的首页</a></li>
<li id="meum" class="f"><a href="">个人中心</a>
<ul id="sub">
<li><a href="">我的资料</a></li>
<li><a href="">修改密码</a></li>
</ul>
</li>
<li class="f"><a href="">我的相册</a></li>
<li class="f">
<a href=""> </a>
</li>
</ul>
<div id="left">
<ul class="left">
<li>全部分类</li>
<li>我的美食</li>
<li>休闲娱乐</li>
<li>爱购物</li>
</ul>
</div>
<div id="right">
<img src="picture/1.jpg" id="first" style="width:300px ; height:440px; margin-left:10px; "/>
<img src="picture/4.jpg" id="second" style="width:300px ; height:440px; margin-left:10px ;"/>
</div>
</div>
</body>
</html>