anans

js macbook 底部菜单效果

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{padding:0;margin:0;}
li{list-style:none;}
#ml0{margin-left:0;}
.box{position:absolute;bottom:0;width:100%;text-align:center;font-size:0;}
.div1{display:inline-block;width:100px;height:100px;margin-left:5px;background:red;}
</style>
</head>
<body>
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<div class="box">
<div id="ml0" class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
</div>
<script>
var box=document.getElementsByClassName(\'box\')[0];
var div1=document.getElementsByClassName(\'div1\');
var input=document.getElementsByTagName(\'input\');
box.onmouseover=function () {
box.onmousemove=function(ev){
var ev=ev || window.event;
for(var i=0;i<div1.length;i++){
var x=div1[i].offsetLeft+div1[i].offsetWidth/2;
var y=div1[i].offsetTop+div1[i].offsetHeight/2+box.offsetTop;
var a=ev.clientX-x;
var b=ev.clientY-y;
var c=Math.sqrt(Math.pow(a,2)+Math.pow(b,2));//取斜线距离
var scale=1-c/1350;//缩小斜线距离值
console.log(c);
if(scale<.5){scale=.5;}
input[i].value=\'X\'+a+\'::Y\'+b;
div1[i].style.width=scale * 130+\'px\';
div1[i].style.height=scale * 130+\'px\';
}
}
};
box.onmouseout=function () {
for(var i=0;i<div1.length;i++){
div1[i].style.width=100+\'px\';
div1[i].style.height=100+\'px\';
}
}
</script>
</body>
</html>

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2021-07-27
  • 2021-11-11
  • 2021-06-11
猜你喜欢
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2021-07-23
相关资源
相似解决方案