{"id":3932,"date":"2024-11-10T09:18:14","date_gmt":"2024-11-10T01:18:14","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3932\/"},"modified":"2024-11-10T09:18:14","modified_gmt":"2024-11-10T01:18:14","slug":"%e5%a6%82%e4%bd%95%e7%a6%81%e7%94%a8-html-%e9%a1%b5%e9%9d%a2%e4%b8%ad%e7%9a%84-ctrl-%e6%bb%9a%e8%bd%ae%e7%bc%a9%e6%94%be%e4%ba%8b%e4%bb%b6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3932\/","title":{"rendered":"\u5982\u4f55\u7981\u7528 HTML \u9875\u9762\u4e2d\u7684 Ctrl \u6eda\u8f6e\u7f29\u653e\u4e8b\u4ef6\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173119842371373.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u7981\u7528 HTML \u9875\u9762\u4e2d\u7684 Ctrl \u6eda\u8f6e\u7f29\u653e\u4e8b\u4ef6\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u7981\u7528 HTML \u9875\u9762\u4e2d\u7684 Ctrl \u6eda\u8f6e\u7f29\u653e\u4e8b\u4ef6\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u7981\u7528 html \u9875\u9762\u4e2d\u4f7f\u7528 ctrl \u6eda\u8f6e\u7f29\u653e\u4e8b\u4ef6<\/strong><\/p>\n<p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u9700\u8981\u7981\u7528 HTML \u9875\u9762\u4e2d\u4f7f\u7528 Ctrl \u6eda\u8f6e\u653e\u5927\u548c\u7f29\u5c0f\u4e8b\u4ef6\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p><strong>1. PC \u7aef<\/strong><\/p>\n<ul>\n<li>\u539f\u751f JavaScript\uff1a<\/li>\n<\/ul>\n<pre>document.addEventListener('mousewheel', function (e) {\n  e = e || window.event;\n  if ((e.wheelDelta &amp;&amp; event.ctrlKey) || e.detail) {\n    event.preventDefault();\n  }\n}, { capture: false, passive: false});\ndocument.addEventListener('keydown', function (event) {\n  if ((event.ctrlKey === true || event.metaKey === true)\n    &amp;&amp; (event.keyCode === 61 || event.keyCode === 107\n      || event.keyCode === 173 || event.keyCode === 109\n      || event.keyCode === 187 || event.keyCode === 189)) {\n    event.preventDefault();\n  }\n}, false);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. Vue \u9875\u9762<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>methods: {\n  keepRatio () {\n    var ratio = 0;  \/\/ \u5b9a\u4e49\u4e00\u4e2a\u7f29\u653e\u6bd4\u4f8b\n    var screen = window.screen;  \/\/ \u83b7\u53d6\u7a97\u53e3\u5bf9\u8c61\n    var ua = navigator.userAgent.toLowerCase();\n    if (window.devicePixelRatio !== undefined) {\n      ratio = window.devicePixelRatio;  \/\/ \u50cf\u7d20\u5927\u5c0f\u7684\u6bd4\u4f8b\n    }\n    else if (ua.indexOf('msie')) {\n      if (screen.deviceXDPI &amp;&amp; screen.logicalXDPI) {\n        ratio = screen.deviceXDPI \/ screen.logicalXDPI;\n      }\n    }\n    else if (window.outerWidth !== undefined &amp;&amp; window.innerWidth !== undefined) {\n      ratio = window.outerWidth \/ window.innerWidth;  \/\/ \u5916\u90e8\u6bd4\u4f8b\/\u5185\u90e8\u6bd4\u4f8b\uff1a\u7f29\u653e\u6bd4\u4f8b\n    }\n    if (ratio) {ratio = Math.round(ratio * 100)}\n    this.ratio = (ratio \/ 100).toFixed(2);\n    document.body.style.zoom = 1 \/ this.ratio;  \/\/ \u7a97\u53e3\u89c6\u56fe\u9664\u4ee5\u7f29\u653e\u6bd4\u4f8b\uff1a\u5373\u7f29\u653e\u8fd8\u539f\n  }\n}\nmounted () {\n  this.keepRatio()\n  window.addEventListener('resize', () =&gt; {\/\/\u76d1\u542c\u7a97\u53e3\u7f29\u653e\n   this.keepRatio()\n  });\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u7981\u7528 HTML \u9875\u9762\u4e2d\u7684 Ctrl \u6eda\u8f6e\u7f29\u653e\u4e8b\u4ef6\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7981\u7528 html \u9875\u9762\u4e2d\u4f7f\u7528 ctrl \u6eda\u8f6e\u7f29\u653e\u4e8b\u4ef6 \u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u9700\u8981\u7981\u7528 HTML \u9875\u9762\u4e2d\u4f7f\u7528 Ctrl \u6eda\u8f6e\u653e\u5927\u548c\u7f29\u5c0f\u4e8b\u4ef6\u3002 \u89e3\u51b3\u65b9\u6848\uff1a 1. PC \u7aef \u539f\u751f JavaScript\uff1a document.addEventListener(&#8216;mousewheel&#8217;, function (e) { e = e || window.event; if ((e.wheelDelta &amp;&amp; event.ctrlKey) || e.detail) { event.preventDefault(); } }, { capture: false, passive: false}); document.addEventListener(&#8216;keydown&#8217;, function (event) { if ((event.ctrlKey === true || event.metaKey === true) &amp;&amp; (event.keyCode === [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-3932","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=3932"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3932\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}