这个怎么样http://jsfiddle.net/sajith/65JEq/我已经相对于绝对定位改变。
HTML
<div id='dots'></div>
的Javascript
$(function() {
var gCurrentDot = 1;
var str = '<div id="1" class="full-circle"></div><span></span>';
for(var i=2; i<=10; i++) {
str += '―<div id="'+(i)+'" class="full-circle"></div><span></span>';
$('#'+ i).css({left: i*10});
}
$("#dots").html(str);
$('.full-circle').click(function() {
$('#'+ gCurrentDot +'').addClass('full-circle-green').animate({height: "30px", width:"30px",marginLeft:"-10px",marginTop:"-5px"}, {duration: 200, complete:function() {
$(this).animate({height: "10px", width:"10px",marginLeft:"0px",marginTop:"5px"}, {duration: 200});
}});
gCurrentDot++;
});
});
CSS
.full-circle {
background-color: rgba(51, 51, 51, 100);
border: 5px solid #333;
border-radius:50%;
height: 10px;
width: 10px;
-moz-border-radius:15px;
-webkit-border-radius: 15px;
display:inline-block;
position:absolute;
margin-top:5px;
}
.full-circle-green {
background-color: rgba(11, 227, 0, 100);
border: 5px solid #333;
border-radius:50%;
height: 10px;
width: 10px;
-moz-border-radius:15px;
-webkit-border-radius: 15px;
display:inline-block;
position:absolute;
}
#dots span {
width: 20px;
height: 20px;
display:inline-block;
}
你必须改变的逻辑。与相对的divs,我不认为你可以做到这一点。必须使用绝对定位。 – SajithNair
这是怎么回事:http://jsfiddle.net/peteng/937mY/9/ – Pete
@Pete看起来更接近OP想要的东西。你应该把它放在答案中。也许考虑在每个圆圈周围放一个容器,然后从圆圈中溢出......这可能会阻止水平推动。 – Askanison4