实例:https://jsfiddle.net/b8vLg0ny/
可以使用CSS scale和translate函数来放大元素.
以这个例子为例,在2x2网格中有4个方框.
HTML:
<div id="container">
<div id="zoom-container">
<div class="box red">A</div>
<div class="box blue">B</div>
<div class="box green">C</div>
<div class="box black">D</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
* { margin: 0; }
body, html { height: 100%; }
#container {
height: 100%;
width: 50%;
margin: 0 auto;
}
#zoom-container {
height: 100%;
width: 100%;
transition: all 0.2s ease-in-out;
}
.box {
float: left;
width: 50%;
height: 50%;
color: white;
text-align: center;
display: block;
}
.red { background: …Run Code Online (Sandbox Code Playgroud) 我必须在按下鼠标时才实现鼠标移动事件.
我只需要在鼠标移动和鼠标移动时执行"OK Moved".
我用过这段代码
$(".floor").mousedown(function() {
$(".floor").bind('mouseover',function(){
alert("OK Moved!");
});
})
.mouseup(function() {
$(".floor").unbind('mouseover');
});
Run Code Online (Sandbox Code Playgroud)