如果您在小提琴中使用 jQuery,这里有一个简单的解决方案DEMO
JS
$(document).ready(function(){
$('a').click(function(e){
e.preventDefault();
var top = $(this).offset().top;
$('#update').css({ 'top': top + 'px' });
});
});
HTML
<div id="holder">
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
Long text <br />
<a href="#">Show Details</a> <br />
<div id="update">Itemlist1</div>
</div>
CSS
#holder {
position: relative;
}
#update {
position: absolute;
left: 100px;
top: 0px;
}