老师帮我看下哪里错了
来源:3-4 行为层
慕少5306396
2019-09-03 17:15:35
$(document).ready(function () {
$('a').click(function(){
$('img')
.eq($(this).index())
.css({'opacity': 1})
.siblings()
.css({'opacity' :0});
});
});
*{
margin: 0px;
padding: 0px;
border: none;
}
html,body{
overflow: hidden;
height: 100%;
background:#93b3c6;
}
span{
display: block;
width: 16px;
height: 16px;
margin: 30px auto 40px;
border-radius: 50%;
background-color: white;
}
nav{
position: relative;
display: flex;
width: 78.125vw;
margin: 0 auto 45px;
justify-content: space-between;
}
nav > a{
position: relative;
font-style: 10px;
padding: 10px;
border: 1px solid #5395b4;
color: #255d7e;
text-decoration: none;
background: #fff;
}
nav before{
position: absolute;
top: 20px;
width: 100%;
height: 10px;
background: #fff;
display: block;
content: '';
}
div {
width: 78.125vw;
height: 75vh;
margin: 0 auto;
background: #fff;
box-shadow: 0 0 30px 0 rgba(8,1,3,.3);
}
div >img{
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 98%;
height: 96%;
margin: auto;
}
<!DOCTYPE html>
<html>
<head>
<title><全屏的云南旅游相册</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style1.css">
<script type="text/javascript" src="js1.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<body>
<span></span>
<nav>
<a href="#">泸沽湖</a>
<a href="#">丽江古城</a>
<a href="#">茶马古道</a>
<a href="#">就这家·云逸客栈</a>
<a href="#">西双版纳</a>
<a href="#">云南红酒庄</a>
<a href="#">轿子雪山</a>
<a href="#">普者黑</a>
<a href="#">海埂大坝</a>
<a href="#">玉龙湾</a>
<a href="#">昆明郊野公园</a>
<a href="#">欧洲风琴小镇</a>
</nav>
<div>
<img src="img/1.jpg">
<img src="img/2.jpg">
<img src="img/3.jpg">
<img src="img/4.jpg">
<img src="img/5.jpg">
<img src="img/6.jpg">
<img src="img/7.jpg">
<img src="img/8.jpg">
<img src="img/9.jpg">
<img src="img/10.jpg">
<img src="img/11.jpg">
<img src="img/12.jpg">
</div>
</body>
</html>
1回答
好帮手慕码
2019-09-03
同学你好!
代码中问题(1)将自己的js文件放在jquery.js文件下
(2)布局是有一些问题的,div中缺少定位和超出隐藏。图片没有居中,缺少left:0

效果:

如果帮助到了你,欢迎采纳,祝学习愉快~
相似问题