{"id":3982,"date":"2024-11-10T09:59:00","date_gmt":"2024-11-10T01:59:00","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3982\/"},"modified":"2024-11-10T09:59:00","modified_gmt":"2024-11-10T01:59:00","slug":"%e5%a6%82%e4%bd%95%e7%a6%81%e7%94%a8-html-%e4%b8%ad%e4%bd%bf%e7%94%a8-ctrl%e6%bb%9a%e8%bd%ae%e6%94%be%e5%a4%a7%e7%bc%a9%e5%b0%8f%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3982\/","title":{"rendered":"\u5982\u4f55\u7981\u7528 HTML \u4e2d\u4f7f\u7528 Ctrl+\u6eda\u8f6e\u653e\u5927\u7f29\u5c0f\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173120563690440.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u7981\u7528 HTML \u4e2d\u4f7f\u7528 Ctrl+\u6eda\u8f6e\u653e\u5927\u7f29\u5c0f\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u7981\u7528 HTML \u4e2d\u4f7f\u7528 Ctrl+\u6eda\u8f6e\u653e\u5927\u7f29\u5c0f\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u7981\u7528 html \u4e2d\u4f7f\u7528 ctrl+\u6eda\u8f6e\u653e\u5927\u7f29\u5c0f<\/strong><\/p>\n<p>\u82e5\u8981\u7981\u7528\u4f7f\u7528 Ctrl+\u6eda\u8f6e\u5bf9 HTML \u5143\u7d20\u8fdb\u884c\u653e\u5927\u7f29\u5c0f\uff0c\u9700\u8981\u91c7\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li><strong>\u539f\u751f JavaScript<\/strong><\/li>\n<\/ol>\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});\n\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});<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li><strong>Vue \u4e2d<\/strong><\/li>\n<\/ol>\n<pre>methods: {\n  keepRatio() {\n    \/\/ \u7f29\u653e\u6bd4\u4f8b\n    var ratio = 0;\n\n    \/\/ \u83b7\u53d6\u7a97\u53e3\u5bf9\u8c61\n    var screen = window.screen;\n\n    var ua = navigator.userAgent.toLowerCase();\n\n    \/\/ \u83b7\u53d6\u50cf\u7d20\u5927\u5c0f\u7684\u6bd4\u4f8b\n    if (window.devicePixelRatio !== undefined) {\n      ratio = window.devicePixelRatio;\n    }\n    \/\/ \u83b7\u53d6 IE \u6d4f\u89c8\u5668\u4e0b\u7684\u7f29\u653e\u6bd4\u4f8b\n    else if (ua.indexOf('msie')) {\n      if (screen.deviceXDPI &amp;&amp; screen.logicalXDPI) {\n        ratio = screen.deviceXDPI \/ screen.logicalXDPI;\n      }\n    }\n    \/\/ \u83b7\u53d6\u5176\u4ed6\u6d4f\u89c8\u5668\u7684\u7f29\u653e\u6bd4\u4f8b\n    else if (window.outerWidth !== undefined &amp;&amp; window.innerWidth !== undefined) {\n      ratio = window.outerWidth \/ window.innerWidth;\n    }\n\n    \/\/ \u4fdd\u7559\u4e24\u4f4d\u5c0f\u6570\n    if (ratio) {\n      ratio = Math.round(ratio * 100);\n    }\n    this.ratio = (ratio \/ 100).toFixed(2);\n\n    \/\/ \u7f29\u653e\u8fd8\u539f\n    document.body.style.zoom = 1 \/ this.ratio;\n  }\n}\nmounted() {\n  this.keepRatio();\n  window.addEventListener('resize', () =&gt; {\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 \u4e2d\u4f7f\u7528 Ctrl+\u6eda\u8f6e\u653e\u5927\u7f29\u5c0f\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 \u4e2d\u4f7f\u7528 ctrl+\u6eda\u8f6e\u653e\u5927\u7f29\u5c0f \u82e5\u8981\u7981\u7528\u4f7f\u7528 Ctrl+\u6eda\u8f6e\u5bf9 HTML \u5143\u7d20\u8fdb\u884c\u653e\u5927\u7f29\u5c0f\uff0c\u9700\u8981\u91c7\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u539f\u751f JavaScript document.addEventListener(&#8216;mousewheel&#8217;, function (e) { e = e || window.event; if ((e.wheelDelta &amp;&amp; event.ctrlKey) || e.detail) { event.preventDefault(); } }); document.addEventListener(&#8216;keydown&#8217;, function (event) { if ((event.ctrlKey === true || event.metaKey === true) &amp;&amp; (event.keyCode === 61 || event.keyCode === 107 || event.keyCode === 173 || 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-3982","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3982","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=3982"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3982\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}