百度 二面 99 乘法表
2021/8/17 23:06:05
本文主要是介绍百度 二面 99 乘法表,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
乘法表
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> * { margin: 0; padding: 0; } body { padding: 20px; } #content { width: 1100px; } .item { margin-bottom: 10px; } .item div { width: 60px; padding: 10px; float: left; border: 1px solid #f00; margin-right: 10px; } .item:after { content: ""; display: block; clear: both; } .item:nth-child(2n) div { background-color: aqua; } .item:nth-child(2n + 1) div { background-color: #ff0; } </style> </head> <body> <div id="content"></div> <script> let fragment = document.createDocumentFragment(); for (var i = 1; i <= 9; i++) { var h = document.createElement("div"); h.classList.add("item"); var arr = []; for (var k = 1; k <= i; k++) { var item = createEle(i, k); h.appendChild(item); } fragment.append(h); } function createEle(a, b) { let div = document.createElement("div"); div.innerHTML = a + "*" + b + "=" + a * b; return div; } let content = document.getElementById("content"); content.appendChild(fragment); setTimeout(function () { // let isdown = false; var _map = {}; content.addEventListener("mousedown", function (e) { // isdown = true // _map = {}; var sx = e.clientX; var sy = e.clientY; _map.sx = sx; _map.sy = sy; console.log(_map, "mousedown"); // _map[e.innerHTML] = e }); content.addEventListener("mouseup", function (e) { var ex = e.clientX; var ey = e.clientY; _map.ex = ex; _map.ey = ey; // var sx = _map.sx // var sy = _map.sy // _map.tl = { // x: sx, // y: sy // } // _map.tr = { // x: ex, // y: sy // } // _map.bl = { // x: sx, // y: ey // } // _map.br = { // x: ex, // y: ey // } console.log(_map, "mouseup"); var res = getInner(_map); console.log(res, "res"); }); // let map = {} content.addEventListener("mousemove", function (e) { // let text = e.target.innerHTML // map[text] = e.target; // console.log(e.target,'e.target') }); }); // window.onload = function(){ function getInner(_map) { let items = document.querySelectorAll(".item div"); var map = []; for (let i = 0; i < items.length; i++) { var pos = item.getBoundingClientRect(); let l = pos.left; let t = pos.top; let w = pos.width; let h = pos.height; var pos = { tl: { x: l, y: t }, tr: { x: l + w, y: t + h }, bl: { x: l, y: t + h }, br: { x: l + w, y: t + h } }; // for (var k in pos) { // var p = pos[k]; // var x = p.x; // var y = p.y; // var { ex, ey, sx, sy } = _map; // console.log(x,y, ex, ey, sx, sy, '000') // let isIn1 = x > sx && x < ex && y > sy && y < ey; // let isIn2 = x < sx && x > ex && y > sy && y < ey; // if (isIn1 || isIn2) { // map.push(item); // } // } } console.log(map, "map"); // } } </script> </body> </html>
这篇关于百度 二面 99 乘法表的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南