あなたのDOMの上部に簡単なHTML要素:抽象化されたCSSと
<div id="highlighter" class="highlight"></div>
スタイルに:あなたは蛍光ペンが一緒にタグ付けする場合
div {
border:1px solid #CCC;
position:relative;
}
#highlighter {
display:none;
border:none;
}
.highlight {
z-index:999999;
background-color:yellow;
opacity:.5;
-moz-opacity:.5;
position:absolute;
width:100%;
height:100%;
}
jQueryのは、もう少し複雑ですあなたのアニメーションのdiv:
$('div').not('.highlight').on('click', function() {
var $this = $(this);
if($this.find('.highlight').length > 0) {
$this.find('.highlight').remove();
} else {
$('#highlighter').clone().appendTo($this).
width($this.width()).
height($this.height()).
css({
'top': '0px',
'left': '0px'
}).
show();
}
});
(function morph(){
$('div').not('.highlight').each(function(){
var $this = $(this);
$this.animate({
'top' : someVal + 'px',
'left' : someVal + 'px',
'width': someVal + 'px',
'left' : someVal + 'px',
}, {
duration: 1000,
step: function(){
// Here we tell the highlighter to sync up with the morphed parent.
$this.find('.highlight').width($this.width()).height($this.height());
},
complete: morph
});
});
}());
デモ:http://jsfiddle.net/AlienWebguy/7t4jT/
ええと、私はそれの脈打つ側面を望んでいない、私はただのハイライトをしたい。 –