无法显示两边按钮

来源:2-3 轮播图上按钮样式

庾松

2019-03-21 13:09:36

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>综合实例</title>
<link rel="stylesheet" type="text/css" href="css/index.css">
<script type="text/javascript" src="js/index.js"></script>
</head>
<body>
<div class="main">
<!--图片轮播-->
<div class="banner">

<a href="#">
<div class="banner_slide slide1 slide_active"></div>
</a>
<a href="#">
<div class="banner_slide slide2"></div>
</a>
<a href="#">
<div class="banner_slide slide3"></div>
</a>
</div>
<!--上一张、下一张按钮-->
<a href="javascript:void(0)" class="button prev"></a>
<a href="javascript:void(0)" class="button next"></a>
</div>
</body>
</html>
*{
	margin: 0;
	padding: 0;
}
ul{
	list-style: none;
}
body{
	font-family: "微软雅黑";
	color: #14191e;
}
.main{
	width: 1200px;
	height: 460px;
	margin: 30px auto;
	overflow: hidden;
	position: relative;
}
.banner{
	width: 1200px;
	height: 460px;
	position: relative;
	overflow: hidden;
}
.banner_slide{
	width: 1200px;
	height: 460px;
	position: absolute;
	background-repeat: no-repeat;
	

}
.slide1{
	background-image: url("../img/bg1.jpg");
}
.slide2{
	background-image: url("../img/bg2.jpg");
}
.slide3{
	background-image: url("../img/bg3.jpg");
}
.slide_active{
	display: block;
}
.button{
	position: absolute;
	width: 40px;
	height: 80px;
	left: 244px;
	top: 50%;
	margin-top: -40%;
	background-color: #0f0;

}
.next{
	left: auto;
	right: 0;

}


写回答

1回答

好帮手慕阿满

2019-03-21

同学你好,在css中设置button时,margin-top是-40px,而不是-40%。如:

http://img.mukewang.com/climg/5c934e2e00013ea703590177.jpg

如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~

0

0 学习 · 9666 问题

查看课程