HBuilder-简易banner制作

代码如下:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<style type="text/css">
			*{
				margin:0;
				padding :0;
			}
			.show{
				width: 400px;
				overflow: hidden;
				position: relative;
			}
			.boxs{
				display: flex;
				width: 1600px;
				margin-left:0px;	
				}
			.box{
				width: 400px;
				position: relative;
			}
			.box>img{
				width:100%;
			}
			.box>p{
				width: 100%;
				position:absolute;
				line-height: 20px;
				background: rgba(0,0,0,0.5);
				bottom:5px;
				color:#fff;
				z-index: 2;
			}
			.con{
				position: absolute;
				width: 100%;
				z-index: 3;
				height: 100%;
			}
			.con>div{
				width: 50px;
				height:50px;
				background:rgba(0,0,0,0.5);
				color: #fff;
				font-size: :36px;
				line-height: 50px;
				text-align: center;
				position: absolute;
				top: 50%;
				margin-top: -25px;
				cursor: pointer;
			}
			.con>div:hover{
				background: #000;
			}
			.right{
				right: 0;
			}
			.balls{
				display: flex;
				position: absolute;
				z-index: 10;
				bottom:10px;
				right:10px;
			}
			.ball{
				width: 10px;
				height: 10px;
				background: rgba(255,255,255,0.5);
				border-radius: 5px;
				margin:5px;
				cursor: pointer;
			}
			.ball:hover{
				background: white;
			}
		</style>
		<script src="js/jquery-3.3.1.min.js"></script>
		<script type="text/javascript">
		$(function(){
			x=0
			$(".right").click(function(){
				x=x-400;
				if(x<-1200){x=0;}
				$(".boxs").css({"margin-left":x+"px"})	
				
			})
			$(".left").click(function(){
				x=x+400;
				if(x>0){x=-1200;}
			
				$(".boxs").css({"margin-left":x+"px"})
			})
			$(".ball").click(function(){
				n=$(this).attr("title")
				x=-400*n
				$(".boxs").css({"margin-left":x+"px"})	
				
				
			})
		})
		</script>
	</script>
	</head>
	<body>
		<div class="show">
			<div class="con">
				<div class="left"><</div>
				<div class="right">></div>
			</div>
			<div class="balls">
				<div class="ball"title="0"></div>
				<div class="ball"title="1"></div>
				<div class="ball"title="2"></div>
				<div class="ball"title="3"></div>
			</div>
			<div class="boxs">
				<div class="box">
					<img src="请自行载入图片" alt="">
					<p>请自行输入文字</p>
				</div>
				<div class="box">
					<img src="请自行载入图片" alt="">
					<p>请自行输入文字</p>
				</div>
				<div class="box">
					<img src="请自行载入图片" alt="">
					<p>请自行输入文字</p>
				</div>
				<div class="box">
					<img src="请自行载入图片" alt="">
					<p>请自行输入文字</p>
				</div>
			</div>
		</div>
	</body>
</html>

效果不展示

点击小球可以切换图片
 点击两侧也可以切换图片

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

妮可珍郝坎

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值