HTML div如何自定义位置(自适应浏览器)。
发布网友
发布时间:2022-04-22 08:55
我来回答
共1个回答
热心网友
时间:2023-12-15 04:18
改了网上一个选项卡切换的小插件,你看有什么不懂的再追问:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<title>demo</title>
<base target="_blank" />
<style type="text/css">
body {
background: url(http://pic1.win4000.com/wallpaper/6/578855acae491.jpg) no-repeat fixed center center;
}
.hovertreepage .clear {
clear: both;
}
.hovertreepage {
width: 100%;
}
.hovertreepage .left,
.hovertreepage .right {
float: left;
}
.hovertreepage .nav-back {
width: 80%;
height: 300px;
background: #000;
opacity: .3;
}
.hovertreepage .nav {
position: relative;
margin-top: -300px;
width: 80%;
text-align: center;
font-size: 14px;
font-family: "微软雅黑";
color: #fff;
}
.hovertreepage .nav div {
height: 32px;
line-height: 28px;
cursor: pointer;
}
.hovertreepage .nav div.on {
background: #0094ea;
}
.hovertreepage .right {
width: 80%;
}
.hovertreepage .content-back {
width: 100%;
height: 300px;
background: #fff;
opacity: .3;
}
.hovertreepage .content {
position: relative;
/* width: 94%; */
height: 300px;
margin-top: -300px;
/* padding: 3% 3% 3% 3%; */
overflow: hidden;
}
.hovertreepage .content a {
color: blue;
}
.hovertreepage .content div {
width: 100%;
height: 300px;
/* margin-bottom: 10px; */
background: #fff;
}
</style>
</head>
<body>
<div class="hovertreepage">
<div class="left" style="width: 20%;">
<div class="nav-back"></div>
<div class="nav">
<div class="on">导航</div>
<div>新闻</div>
<div>世界杯</div>
<div>音乐</div>
<div>彩票</div>
</div>
</div>
<div class="right">
<div class="content-back"></div>
<div class="content">
<div style="background: #DCDCDC;">
<a href="javascropt:void(0)">首页</a>
<a href="javascropt:void(0)">特效</a>
<a href="http://hovertree.com/h/bjaf/n781jmfy.htm">原文</a>
</div>
<div style="background: #3695d5;">222</div>
<div style="background: #039702;">
<a href="javascropt:void(0)">333</a>
</div>
<div style="background: #009688;">
<a href="javascropt:void(0)">4444</a>
</div>
<div>
<a href="javascropt:void(0)"><img src="http://pic1.win4000.com/wallpaper/6/578855acae491.jpg" alt="" style="width: 100%;height: 100%;float: left;" /></a>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<script type="text/javascript" src="http://down.hovertree.com/jquery/jquery-1.12.3.min.js"></script>
<script type="text/javascript">
$(".hovertreepage .nav div").mouseenter(function() {
var $this = $(this);
var index = $this.index();
}).mouseleave(function() {
var $this = $(this);
var index = $this.index();
}).click(function() {
var $this = $(this);
var index = $this.index();
var l = -(index * 300);
$(".hove" + "rtreepage .nav div").removeClass("on");
$(".hovertreepage .nav div").eq(index).addClass("on");
$(".hovertreepage .content div:eq(0)").stop().animate({
"margin-top": l
}, 500);
});
</script>
</body>
</html>