.continer { width:500px; margin:20px auto; border:1px solid #ccc; overflow:hidden; height:200px; position:relative; } .continer ul { width:2500px; margin:0; padding:0; list-style:none; position:absolute; } .continer ul li { float:left; margin:0; padding:0; background:#ffff00; width:500px; height:200px; display:none; } .continer ul li:nth-child(1) { background:#000080; } .continer ul li:nth-child(2) { background:#0BB20C; } .continer ul li:nth-child(3) { background:#9B9B9B; } .continer ul li:nth-child(4) { background:#007aff; } .continer ul li:nth-child(5) { background:#F00; } .dot { position:absolute; bottom:30px; right:50px; } .dot span { display:inline-block; width:10px; height:10px; border-radius:50%; margin-left:20px; border:1px solid #ccc; background:#fff; } .dot span.active { background:#000000; } .continer button { width:40px; height:40px; background:#000; opacity:0.5; text-align:center; line-height:40px; color:#fff; border:none; display:none; } .continer .prev { position:absolute; left:0px; top:50%; margin-top:-20px; z-index:5; } .continer .next { position:absolute; right:0px; top:50%; margin-top:-20px; z-index:5; }
轮播图是项目常用的效果,本案例是自己刚学会面向对象,写的代码,不是太精炼。希望大神给出指点