<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>动态生成小圆点</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
div{
width: 100px;
height: 100px;
overflow: hidden;
margin: 300px 50%;
position: relative;
border: 1px solid #5EFF5E;
}
div img{
display: inline-block;
width: 100px;
height: 100px;
}
div ul{
position: absolute;
bottom: 10px;
line-height: 5px;
width: 100px;
height: 5px;
text-align: center;
}
div ul li{
width: 5px;
height: 5px;
border-radius: 10px;
background-color: #5EFF5E;
display: inline-block;
margin: 2px;
text-align: center;
}
</style>
<script type="text/javascript">
window.onload = function(){
var box = document.getElementById("box");
var ul = document.getElementById("ul");
var img = document.getElementsByTagName("img");
for(var i=0; i<img.length; i++){
var li = document.createElement("li");
ul.appendChild(li);
}
}
</script>
</head>
<body>
<div id="box">
<img src="../images/03.jpg"/>
<img src="../images/03.jpg"/>
<img src="../images/03.jpg"/>
<img src="../images/03.jpg"/>
<ul id="ul">
</ul>
</div>
</body>
</html>
效果: