{"id":9216,"date":"2020-01-17T01:05:59","date_gmt":"2020-01-16T17:05:59","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=9216"},"modified":"2020-01-17T01:05:59","modified_gmt":"2020-01-16T17:05:59","slug":"css-any-hover-media","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2020\/01\/css-any-hover-media\/","title":{"rendered":"CSS any-hover any-pointer media\u67e5\u8be2\u4e0e\u4ea4\u4e92\u4f53\u9a8c\u63d0\u5347"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=5474\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=5474<\/a><br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202001-media-hover-pointer.png';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/202001\/media-hover-pointer.png\" width=\"480\" height=\"315\" alt=\"media\u5a92\u4f53\u67e5\u8be2\u6587\u7ae0\u5934\u56fe\" class=\"alignnone clip thumb size-medium\" \/><\/p>\n<h3>\u4e00\u3001CSS\u5224\u65ad\u662f\u5426\u662f\u89e6\u6478\u8bbe\u5907<\/h3>\n<p>\u9065\u60f3\u6570\u5e74\u524d\uff0c\u60f3\u8981\u5b9e\u73b0\u4e00\u4e2a\u529f\u80fd\uff0c\u5982\u679c\u662f\u624b\u673a\u4e0a\u6216\u8005\u5e73\u677f\u8bbe\u5907\uff0c\u5219\u9875\u9762\u4e0a\u94fe\u63a5\u4e0d\u663e\u793a\u4e0b\u5212\u7ebf\uff0c\u4ec5\u4ec5\u989c\u8272\u53d8\u5316\u3002\u800cPC\u6d4f\u89c8\u5668\u8bbf\u95ee\u9875\u9762\uff0c\u4e0b\u5212\u7ebf\u4f9d\u7136\u4fdd\u7559\uff0c\u7136\u540ehover\u65f6\u5019\u9690\u85cf\u3002<\/p>\n<p>\u539f\u56e0\u662f\u79fb\u52a8\u8bbe\u5907\u4e0ahover\u6548\u679c\u6ca1\u6709\u684c\u9762\u6d4f\u89c8\u5668\u90a3\u4e48\u7cbe\u51c6\uff0c\u4f53\u9a8c\u5e76\u4e0d\u597d\u3002<\/p>\n<p>\u5f53\u65f6\u627e\u4e86\u5f88\u591a\u8d44\u6599\uff0c\u5404\u79cd\u7279\u6027\u5c1d\u8bd5\uff0c\u5438\u5f15\u53ef\u4ee5\u7eafCSS\u5224\u65ad\u662f\u4e0d\u662f\u652f\u6301\u624b\u6307\u70b9\u51fb\u7684\u8bbe\u5907\uff0c\u672a\u679c\u3002\u901a\u8fc7\u5224\u65ad\u5c4f\u5e55\u5bc6\u5ea6\uff0c\u82f9\u679c\u7535\u8111\u8fd8\u6709\u65b0\u7684\u663e\u793a\u5668\u90fd\u662f\u591a\u500d\u5c4f\uff0c\u6709\u95ee\u9898\uff1b\u901a\u8fc7\u5224\u65ad\u5c4f\u5e55\u5c3a\u5bf8\u7684\u8bdd\uff0c\u53c8\u65e0\u6cd5\u533a\u5206\u5e73\u677f\u8bbe\u5907\u3002\u6700\u540e\u653e\u5f03\u3002<\/p>\n<p>\u7136\u540e\u6700\u8fd1\u5076\u7136\u9047\u5230\u4e00\u4e2a\u65b0\u7684media\u5a92\u4f53\u67e5\u8be2\u6761\u4ef6\uff0c<code>any-hover<\/code>\uff0c\u5c45\u7136\u53ef\u4ee5\u5224\u65ad\u8bbe\u5907\u662f\u5426\u652f\u6301\u9f20\u6807\u7ecf\u8fc7\u884c\u4e3a\uff0c\u5927\u559c\uff01\u8fd9\u4e0d\u6b63\u597d\u53ef\u4ee5\u89e3\u51b3\u6211\u591a\u5e74\u524d\u7684\u90a3\u4e2a\u4f53\u9a8c\u589e\u5f3a\u9700\u6c42\u5417\uff1f<\/p>\n<p>\u4e0b\u9762\u8fd9\u6bb5CSS\u4ee3\u7801\u5c31\u53ef\u4ee5\u4e86\uff1a<\/p>\n<pre>@media (any-hover: none) {\r\n  a {\r\n    text-decoration: none;\r\n  }\r\n}<\/pre>\n<p>\u8fd9\u6837\uff0c\u5c31\u53ef\u4ee5\u8ba9\u94fe\u63a5\u5728\u4e8e\u4e0d\u652f\u6301\u9f20\u6807hover\u7684\u8bbe\u5907\u4e0b\u6ca1\u6709\u4e0b\u5212\u7ebf\u4e86\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u5b9e\u5730\u6d4b\u8bd5\u4e0b\uff0c\u4e0b\u9762\u8fd9\u6bb5\u6587\u5b57\u6709\u6ca1\u6709\u4e0b\u5212\u7ebf\u5462\uff1f\u5982\u679c\u4e0d\u51fa\u610f\u5916\uff0c\u624b\u673a\u8bbf\u95ee\u6ca1\u6709\u4e0b\u5212\u7ebf\uff0c\u4f46\u662f\u6709\u9e45\u9ec4\u8272\u4eae\u4eae\u7684\u80cc\u666f\u8272\uff1b\u684c\u9762\u6d4f\u89c8\u5668\u8bbf\u95ee\u5219\u662f\u4e0b\u5212\u7ebf\u3002<\/p>\n<style>.any-hover { border: 2px solid #cd0000; padding: 10px; font-family: kaiti, stKaiTi; }@media (any-hover: none) {  .any-hover {    text-decoration: none;background-color: #ffffe0;  }}@media (any-hover: hover) {  .any-hover {    text-decoration: underline;}}<\/style>\n<p><span class=\"any-hover\">\u300aCSS\u9009\u62e9\u5668\u4e16\u754c\u300b<a href=\"https:\/\/e.jd.com\/30567539.html\" rel=\"noopener\" target=\"_blank\">\u7535\u5b50\u4e66<\/a>\u5df2\u7ecf\u4e0a\u67b6\u4e86\uff0c\u559c\u6b22\u9605\u8bfb\u7535\u5b50\u4e66\u7684\u670b\u53cb\u4e0d\u8981\u9519\u8fc7\u54e6\uff01<\/span><\/p>\n<p>\u7528\u5230\u7684CSS\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>@media (any-hover: none) {\r\n  .example-zxx {\r\n    text-decoration: none;\r\n    background-color: #ffffe0;\r\n  }\r\n}\r\n@media (any-hover: hover) {\r\n  .example-zxx {\r\n    text-decoration: underline;\r\n  }\r\n}<\/pre>\n<h3>\u4e8c\u3001any-hover\u5a92\u4f53\u67e5\u8be2\u7b80\u4ecb<\/h3>\n<p><code>any-hover<\/code> CSS\u5a92\u4f53\u529f\u80fd\u53ef\u7528\u4e8e\u6d4b\u8bd5\u662f\u5426\u6709\u4efb\u610f\u53ef\u7528\u7684\u8f93\u5165\u88c5\u7f6e\u53ef\u4ee5hover\u60ac\u505c\u5728\u5143\u7d20\u4e0a\u3002<\/p>\n<p>\u4f8b\u5982\u9f20\u6807\u8fd9\u4e2a\u8f93\u5165\u88c5\u7f6e\u5c31\u53ef\u4ee5\u63a7\u5236cursor\u624b\u5f62\u7684\u4f4d\u7f6e\uff0c\u4ee5\u53cahover\u5728\u5143\u7d20\u4e0a\uff1b\u4f8b\u5982\u624b\u673a\u90fd\u662f\u624b\u6307\u63a7\u5236\uff0c\u6ca1\u6709\u4ec0\u4e48\u60ac\u505c\u611f\u5e94\uff0c\u56e0\u6b64\uff0c\u6ca1\u6709\u88c5\u7f6e\u53ef\u4ee5hover\u60ac\u505c\uff08\u867d\u7136\u624b\u6307\u4e5f\u80fd\u89e6\u53d1<code>:hover<\/code>\u4f2a\u7c7b\u6548\u679c\uff09\u3002<\/p>\n<p>\u56e0\u6b64\uff0c<code>any-hover<\/code>\u5a92\u4f53\u67e5\u8be2\u7b80\u4ecb\u53ef\u4ee5\u7528\u6765\u7cbe\u786e\u63a7\u5236\u4e0d\u540c\u8bbe\u5907\u4e0a\u7684hover\u4ea4\u4e92\u884c\u4e3a\uff0c\u5c24\u5176\u5bf9\u4e8e\u8de8\u5e73\u53f0\u7684\u7f51\u9875\uff0c\u54cd\u5e94\u5f0f\u7f51\u7ad9\uff0c\u975e\u5e38\u6709\u7528\u3002<\/p>\n<h4>\u8bed\u6cd5<\/h4>\n<p><code>any-hover<\/code>\u529f\u80fd\u68c0\u6d4b\u652f\u6301\u4e0b\u9762\u4e24\u4e2a\u5173\u952e\u5b57\u503c\uff1a<\/p>\n<dl>\n<dt><strong>none<\/strong><\/dt>\n<dd>\u6ca1\u6709\u4ec0\u4e48\u8f93\u5165\u88c5\u7f6e\u53ef\u4ee5\u5b9e\u73b0hover\u60ac\u505c\uff0c\u6216\u8005\u6ca1\u6709\u53ef\u4ee5\u6307\u5411\u7684\u8f93\u5165\u88c5\u7f6e\u3002<\/dd>\n<dt><strong>hover<\/strong><\/dt>\n<dd>\u4e00\u4e2a\u6216\u591a\u4e2a\u8f93\u5165\u88c5\u7f6e\u53ef\u4ee5\u89e6\u53d1\u5143\u7d20\u7684hover\u60ac\u505c\u4ea4\u4e92\u3002<\/dd>\n<\/dl>\n<h4>\u5e94\u7528\u4e3e\u4f8b<\/h4>\n<p>\u51e0\u4e4e\u6240\u6709\u7684\u5916\u90e8\u7f51\u9875\u90fd\u79bb\u4e0d\u5f00\u6309\u94ae\u3002<\/p>\n<p>\u5982\u679c\u6211\u4eec\u7684\u7f51\u7ad9\u662f\u4e13\u4e3a\u79fb\u52a8\u7aef\u5f00\u53d1\u7684\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5199\u6309\u94ae\u9ed8\u8ba4\u6001\u548c:active\u6fc0\u6d3b\u6001\u5c31\u53ef\u4ee5\u3002<\/p>\n<p>\u4f46\u662f\u5982\u679c\u6211\u4eec\u5e0c\u671b\u5199\u4e00\u4e2a\u6309\u94ae\u7ec4\u4ef6\uff0c\u5728\u79fb\u52a8\u7aef\u548cPC\u7aef\u901a\u7528\uff0c\u90a3\u4e48\uff0cPC\u7aef\u9700\u8981\u7684:hover\u6548\u679c\u7528\u5728\u79fb\u52a8\u7aef\u5c31\u4e0d\u5408\u9002\uff0c\u6b64\u65f6\u53ef\u4ee5\u501f\u52a9<code>any-hover<\/code>\u5a92\u4f53\u67e5\u8be2\u4f18\u5316\u6211\u4eec\u7684\u4f53\u9a8c\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>button {\r\n    background-color: #fff;\r\n}\r\nbutton:active {\r\n    background-color: #f0f0f0;\r\n}\r\n@media (any-hover: hover) {\r\n  button:hover {\r\n    background-color: #f5f5f5;\r\n  }\r\n}<\/pre>\n<p>\u4f46\u662f\uff0c\u8fd9\u6837\u6709\u4e2a\u95ee\u9898\uff0c\u5c31\u662fIE\u6d4f\u89c8\u5668\u4e0b\u7684\u6309\u94ae<code>:hover<\/code>\u6548\u679c\u6ca1\u6709\u4e86\uff0c\u56e0\u4e3a<code>@media (any-hover: hover)<\/code> Edge16\u624d\u652f\u6301\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/202001\/2020-01-16_222344.png\" width=\"637\" height=\"280\" alt=\"any-hover\u5a92\u4f53\u67e5\u8be2\u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u6709\u4ec0\u4e48\u529e\u6cd5\u5462\uff1f<\/p>\n<p>\u6709\uff01\u90a3\u5c31\u662f\u653e\u5f03IE\u6d4f\u89c8\u5668\uff01<\/p>\n<p>\u6216\u8005\u6539\u7528\u4e0b\u9762\u7684<code>hover<\/code>\u5a92\u4f53\u67e5\u8be2\uff0c\u53ef\u4ee5\u517c\u5bb9\u5230Edge12\u3002<\/p>\n<h3>\u4e09\u3001\u90a3hover\u5a92\u4f53\u67e5\u8be2\u4ec0\u4e48\u610f\u601d\u5462\uff1f<\/h3>\n<p>\u548c<code>any-hover<\/code>\u8fd1\u4f3c\u7684\u8fd8\u6709\u4e00\u4e2ahover\u5a92\u4f53\u67e5\u8be2\u3002<\/p>\n<p>\u8bed\u6cd5\u4e00\u6837\u4f5c\u7528\u4e5f\u662f\u4e00\u6837\u7684\uff0c\u552f\u4e00\u7684\u533a\u522b\u5c31\u5728\u4e8e<code>any-hover<\/code>\u662f\u68c0\u6d4b\u4efb\u610f\u7684\u8f93\u5165\u88c5\u7f6e\uff0c\u800c<code>hover<\/code>\u53ea\u68c0\u6d4b\u4e3b\u8981\u7684\u8f93\u5165\u88c5\u7f6e\u3002<\/p>\n<h4>\u8bed\u6cd5<\/h4>\n<p><code>hover<\/code>\u529f\u80fd\u68c0\u6d4b\u652f\u6301\u4e0b\u9762\u4e24\u4e2a\u5173\u952e\u5b57\u503c\uff1a<\/p>\n<dl>\n<dt><strong>none<\/strong><\/dt>\n<dd>\u4e3b\u8f93\u5165\u88c5\u7f6e\u6839\u672c\u65e0\u6cd5\u60ac\u505c\u6216\u65e0\u6cd5\u65b9\u4fbf\u5730\u60ac\u505c\uff08\u4f8b\u5982\uff0c\u8bb8\u591a\u79fb\u52a8\u8bbe\u5907\u5728\u7528\u6237\u6267\u884c\u4e0d\u65b9\u4fbf\u7684\u957f\u70b9\u51fb\u6765\u6a21\u62df\u60ac\u505c\uff09\uff0c\u6216\u8005\u6ca1\u6709\u4e3b\u6307\u5411\u8f93\u5165\u88c5\u7f6e\u3002<\/dd>\n<dt><strong>hover<\/strong><\/dt>\n<dd>\u4e3b\u8f93\u5165\u88c5\u7f6e\u53ef\u4ee5\u89e6\u53d1\u5143\u7d20\u7684hover\u60ac\u505c\u4ea4\u4e92\u3002<\/dd>\n<\/dl>\n<h4>\u517c\u5bb9\u6027<\/h4>\n<p><code>hover<\/code>\u517c\u5bb9\u5230Edge12\uff0cwindow8+\u4ee5\u4e0a\u64cd\u4f5c\u7cfb\u7edf\u90fd\u53ef\u4ee5\u4f7f\u7528\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/202001\/2020-01-16_235350.png\" width=\"567\" height=\"284\" alt=\"hover media\u67e5\u8be2\u517c\u5bb9\u6027\u622a\u56fe\" class=\"alignnone size-medium\" \/><\/p>\n<h3>\u56db\u3001pointer\u548cany-pointer\u7b80\u4ecb<\/h3>\n<p>\u4e0e<code>hover<\/code>\u3001<code>any-hover<\/code>\u67e5\u8be2\u76f8\u5bf9\u5e94\u7684\u8fd8\u6709<code>pointer<\/code>\u3001<code>any-pointer<\/code>\u67e5\u8be2\u3002<\/p>\n<p><code>hover<\/code>\u662f\u60ac\u505c\u4e8b\u4ef6\u76f8\u5173\uff0c\u800c<code>pointer<\/code>\u5219\u662f\u4e0e\u70b9\u51fb\u4e8b\u4ef6\u76f8\u5173\u3002<\/p>\n<p><code>pointer<\/code>\u3001<code>any-pointer<\/code>\u67e5\u8be2\u4e3b\u8981\u7528\u6765\u8bc6\u522b\u5f53\u524d\u7684\u73af\u5883\uff0c\u662f\u5426\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u8fdb\u884c\u70b9\u51fb\u64cd\u4f5c\u3002<\/p>\n<h4>any-pointer\u8bed\u6cd5<\/h4>\n<p>\u652f\u6301\u4e0b\u97623\u4e2a\u5173\u952e\u5b57\u503c\uff1a<\/p>\n<dl>\n<dt><strong>none<\/strong><\/dt>\n<dd>\u6ca1\u6709\u53ef\u7528\u7684\u70b9\u51fb\u8bbe\u5907\u3002<\/dd>\n<dt><strong>coarse<\/strong><\/dt>\n<dd>\u81f3\u5c11\u4e00\u4e2a\u8bbe\u5907\u7684\u70b9\u51fb\u4e0d\u662f\u5f88\u7cbe\u786e\u3002\u4f8b\u5982\u624b\u673a\u79fb\u52a8\u7aef\uff0c\u7528\u7f57\u6c38\u6d69\u7684\u8bdd\u8bb2\uff0c\u90fd\u662f\u4f7f\u7528\u841d\u535c\u4e00\u6837\u7c97\u7684\u624b\u673a\u8fdb\u884c\u64cd\u4f5c\uff0c\u5c31\u5c5e\u4e8e\u70b9\u51fb\u4e0d\u7cbe\u786e\u3002<\/dd>\n<dt><strong>fine<\/strong><\/dt>\n<dd>\u6709\u8bbe\u5907\u53ef\u4ee5\u8ba9\u70b9\u51fb\u5f88\u7cbe\u51c6\u3002\u4f8b\u5982\u6709\u9f20\u6807\u7684\u684c\u9762\u7535\u8111\u6d4f\u89c8\u5668\u3002<\/dd>\n<\/dl>\n<h4>pointer\u8bed\u6cd5<\/h4>\n<p>\u540c\u6837\u4e5f\u662f\u652f\u6301\u4e0b\u97623\u4e2a\u5173\u952e\u5b57\u503c\uff1a<\/p>\n<dl>\n<dt><strong>none<\/strong><\/dt>\n<dd>\u4e3b\u8f93\u5165\u88c5\u7f6e\u70b9\u51fb\u4e0d\u53ef\u7528\u3002<\/dd>\n<dt><strong>coarse<\/strong><\/dt>\n<dd>\u4e3b\u8f93\u5165\u88c5\u7f6e\u70b9\u51fb\u4e0d\u7cbe\u786e\u3002<\/dd>\n<dt><strong>fine<\/strong><\/dt>\n<dd>\u4e3b\u8f93\u5165\u88c5\u7f6e\u70b9\u51fb\u5f88OK\u3002<\/dd>\n<\/dl>\n<h4>\u5e94\u7528\u573a\u666f<\/h4>\n<p><code>pointer<\/code>\u548c<code>any-pointer<\/code>\u67e5\u8be2\u8bed\u6cd5\u8bbe\u8ba1\u7684\u521d\u8877\u975e\u5e38\u597d\uff0c\u5f53\u6211\u4eec\u77e5\u9053\u4e00\u4e2a\u8bbe\u5907\u70b9\u51fb\u662f\u5426\u7cbe\u786e\u8fd8\u662f\u4e0d\u7cbe\u786e\u4e4b\u540e\uff0c\u6211\u4eec\u5c31\u80fd\u8fdb\u884c\u76f8\u5e94\u7684\u4f53\u9a8c\u5347\u7ea7\u548c\u6539\u8fdb\u3002<\/p>\n<p>\u6bd4\u65b9\u8bf4\u5982\u679c\u7528\u6237\u7684\u70b9\u51fb\u64cd\u4f5c\u53ef\u4ee5\u5f88\u7cbe\u786e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u4f20\u7edf\u6309\u94ae\uff1b\u5982\u679c\u7528\u6237\u7684\u70b9\u51fb\u64cd\u4f5c\u4e0d\u662f\u5f88\u7cbe\u786e\uff0c\u90a3\u6211\u4eec\u5c31\u53ef\u4ee5\u505a\u4e00\u4e2a\u5927\u5927\u5bbd\u5bbd\u7684\u6309\u94ae\uff0c\u65b9\u4fbf\u7528\u6237\u64cd\u4f5c\u3002<\/p>\n<p>\u4f46\u662f\u653e\u5230\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u5e76\u6ca1\u6709\u505a\u8fd9\u6837\u7684\u533a\u5206\uff0c\u90fd\u662f\u76f4\u63a5\u4f18\u96c5\u5730\u6269\u5927\u70b9\u51fb\u533a\u57df\uff0c\u4f8b\u5982<code>&lt;a&gt;<\/code>\u5305\u542b\u6574\u6bb5\u63cf\u8ff0\uff0c\u6309\u94ae\u505a\u5f97\u8db3\u591f\u5927\u3002\u5c0f\u56fe\u6807\u6309\u94ae\u4e5f\u4f7f\u7528<code>padding<\/code>\u6216\u8005\u900f\u660e<code>border<\/code>\u6269\u5c55\u70b9\u51fb\u533a\u57df\u3002<\/p>\n<p>\u6839\u672c\u8f6e\u4e0d\u5230\u4f7f\u7528<code>pointer<\/code>\u548c<code>any-pointer<\/code>\u67e5\u8be2\u8bed\u6cd5\u8fdb\u884c\u533a\u5206\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\uff0c<code>pointer<\/code>\u548c<code>any-pointer<\/code>\u6700\u5b9e\u7528\u7684\u573a\u666f\u5176\u5b9e\u5e76\u4e0d\u662f\u79fb\u52a8\u7aef\uff0c\u53cd\u800c\u662f\u5bbd\u5c4f\u7684PC\u7f51\u9875\u3002<\/p>\n<p>\u968f\u7740\u7269\u8054\u7f51\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u4ee5\u540e\u4f1a\u51fa\u73b0\u5404\u79cd\u5404\u6837\u7684\u89e6\u5c4f\u8bbe\u5907\uff0c\u4ed6\u4eec\u5c3a\u5bf8\u90fd\u662f\u5f88\u5927\u7684\uff0c\u6bd4\u5982\u8bf4\u7279\u65af\u62c9\u7684\u4e2d\u63a7\u5c4f\uff0c\u533b\u9662\u6216\u94f6\u884c\u7684\u81ea\u52a9\u673a\u5c4f\u5e55\uff0c\u6216\u8005\u5404\u79cd\u5e73\u677f\u8bbe\u5907\u7b49\u3002<\/p>\n<p>\u5728\u8fd9\u4e9b\u8bbe\u5907\u4e0a\u6d4f\u89c8\u7f51\u9875\u7684\u65f6\u5019\uff0c\u7531\u4e8e\u4ed6\u4eec\u7684\u8bbe\u5907\u5bbd\u5ea6\u8db3\u591f\u7684\u5927\uff0c1200\u50cf\u7d20\u4ee5\u4e0a\uff0c\u663e\u793a\u7684\u662f\u6211\u4eec\u684c\u9762\u7aef\u7684\u7f51\u9875\u3002<\/p>\n<p>\u800c\u6211\u4eec\u5728\u5f00\u53d1\u684c\u9762\u5f53\u7f51\u9875\u7684\u65f6\u5019\uff0c\u5f80\u5f80\u90fd\u662f\u57fa\u4e8e\u7528\u6237\u6709\u4e00\u4e2a\u7075\u654f\u7684\u9f20\u6807\u6765\u8bbe\u8ba1\u548c\u5f00\u53d1\u7684\uff0c\u8fd9\u5c31\u4f1a\u5bfc\u81f4\u5728\u5927\u5c4f\u89e6\u6478\u8bbe\u5907\u4e0b\u5e26\u6765\u4f53\u9a8c\u95ee\u9898\u3002<\/p>\n<p>\u6bd4\u65b9\u8bf4\u6d4f\u89c8\u5668\u7684\u5355\u9009\u6846\u548c\u590d\u9009\u6846\uff0c\u5176\u5b9e\u662f\u5f88\u5c0f\u7684\u4e00\u5757\u533a\u57df\uff0c\u5982\u679c\u6211\u4eec\u7528\u9f20\u6807\u70b9\uff0c\u5176\u5b9e\u8fd8\u633a\u597d\u70b9\u51fb\u7684\uff0c\u5982\u679c\u662f\u5728\u5e73\u677f\u8bbe\u5907\u4e0a\uff0c\u7528\u624b\u6307\u53bb\u6233\uff0c\u770b\u4f60\u5c31\u4e0d\u592a\u597d\u70b9\u51fb\u3002<\/p>\n<p>\u8fd9\u4e2a\u65f6\u5019\uff0c<code>pointer<\/code>\u548c<code>any-pointer<\/code>\u67e5\u8be2\u5c31\u5f88\u6709\u7528\u4e86\u3002<\/p>\n<p>\u4f8b\u5982\u70b9\u51fb\u4e0d\u7cbe\u786e\u7684\u65f6\u5019\u8ba9\u590d\u9009\u6846\u5c3a\u5bf8\u53d8\u5927\uff1a<\/p>\n<pre>@media (pointer: coarse) {\r\n  input[type=\"checkbox\"] {\r\n    width: 30px;\r\n    height: 30px;\r\n  }\r\n}<\/pre>\n<p>\u5b9e\u65f6\u6548\u679c\u5982\u4e0b\uff08\u624b\u673a\u6216\u8005Pad\uff0c\u6216\u8005\u5176\u4ed6\u89e6\u6478\u8bbe\u5907\uff0c\u590d\u9009\u6846\u5c3a\u5bf8\u4f1a\u660e\u663e\u6bd4\u6587\u5b57\u5927\uff09\uff1a<\/p>\n<style>@media (pointer: coarse) {  .pointer-coarse {    width: 30px;    height: 30px;  }}<\/style>\n<p style=\"padding: 10px; border: 1px dashed deepskyblue; text-align: center;\">\u590d\u9009\u6846\uff1a<input class=\"pointer-coarse\" type=\"checkbox\"><\/p>\n<p>\u5982\u679c\u4f60\u662f\u5728\u684c\u9762\u6d4f\u89c8\u5668\u8bbf\u95ee\u672c\u6587\uff0c\u53ef\u4ee5\u6253\u5f00\u63a7\u5236\u53f0\u8fdb\u5165\u79fb\u52a8\u9884\u89c8\u6a21\u5f0f\uff0c\u4e5f\u4f1a\u770b\u5230\u590d\u9009\u6846\u53d8\u5f97\u5f88\u5927\uff0c\u5988\u5988\u518d\u4e5f\u4e0d\u7528\u62c5\u5fc3\u6211\u70b9\u4e0d\u5230\u6309\u94ae\u63a7\u4ef6\u4e86\u3002<\/p>\n<h4>\u517c\u5bb9\u6027<\/h4>\n<p><code>pointer<\/code>\u548c<code>any-pointer<\/code>\u67e5\u8be2\u8bed\u6cd5\u90fd\u662fEdge 12+\u5f00\u59cb\u652f\u6301\u7684\uff0c\u5728CSS\u65b0\u7279\u6027\u91cc\u9762\u7b97\u662f\u517c\u5bb9\u6027\u4e0d\u9519\u7684\u5566\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/202001\/2020-01-17_002917.png\" width=\"570\" height=\"276\" alt=\"any-pointer\u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/202001\/2020-01-17_002905.png\" width=\"565\" height=\"276\" alt=\"media pointer\u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<h3>\u4e94\u3001\u70b9\u8bc4\u3001\u7ed3\u8bed\u53ca\u5176\u4ed6<\/h3>\n<p>\u672c\u6587\u4ecb\u7ecd\u7684\u9f20\u6807hover\u60ac\u505c\u5a92\u4f53\u67e5\u8be2\uff0c\u4ee5\u53ca\u70b9\u51fbpointer\u5a92\u4f53\u67e5\u8be2\u53ef\u4ee5\u6709\u6548\u5730\u533a\u5206\u89e6\u5c4f\u8bbe\u5907\u548c\u975e\u89e6\u5c4f\u8bbe\u5907\u3002<\/p>\n<p>\u4f46\u662f\u76ee\u524d\u800c\u8a00\uff0c\u6211\u4eec\u8c08\u5230\u89e6\u5c4f\u8bbe\u5907\u548c\u975e\u89e6\u5c4f\u8bbe\u5907\uff0c\u5f80\u5f80\u6307\u7684\u5c31\u662f\u624b\u673a\u7aef\u6d4f\u89c8\u5668\u548c\u684c\u9762\u7aef\u6d4f\u89c8\u5668\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u672c\u6587\u4ecb\u7ecd\u8fd9\u4e9b\u67e5\u8be2\u7279\u6027\uff0c\u5176\u771f\u6b63\u7684\u4ef7\u503c\u5e76\u4e0d\u662f\u7528\u5728\u624b\u673a\u7aef\u5f00\u53d1\u4e0a\u3002\u56e0\u4e3a\u624b\u673a\u7684\u5c4f\u5e55\u5c3a\u5bf8\u5bbd\u5ea6\u662f\u6709\u9650\u7684\uff0c\u6211\u4eec\u901a\u5e38\u4f1a\u4e3a\u4e86\u8fd9\u4e2a\u8bbe\u5907\u4e13\u95e8\u5b9a\u5236\u4e00\u5957\u6211\u4eec\u7684\u7f51\u9875\u5185\u5bb9\uff0c\u5176\u4ea4\u4e92\u7ec6\u8282\u5e03\u5c40\u4ee5\u53ca\u4f53\u9a8c\u554a\uff0c\u90fd\u662f\u6709\u4e13\u95e8\u505a\u8fc7\u4f18\u5316\u5904\u7406\u7684\uff0c\u8fd8\u8f6e\u4e0d\u5230\u9700\u8981\u4f7f\u7528hover\u548cpointer\u5a92\u4f53\u67e5\u8be2\u8fdb\u884c\u4f18\u5316\u3002<\/p>\n<p>\u53cd\u800c\u66f4\u52a0\u9002\u7528\u573a\u666f\u662f\u684c\u9762\u7aef\u6d4f\u89c8\u5668\u9875\u9762\uff0c\u5f53\u6211\u4eec\u4f7f\u7528\u5927\u5c4f\u7684\u89e6\u5c4f\u8bbe\u5907\u8bbf\u95ee\u6211\u4eec\u7684\u4f20\u7edf\u7f51\u9875\u7684\u65f6\u5019\uff0chover\u548cpointer\u5a92\u4f53\u67e5\u8be2\u7684\u4ef7\u503c\u624d\u80fd\u591f\u5f97\u5230\u5927\u5927\u7684\u4f53\u73b0\u3002<\/p>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5f88\u591a\u684c\u9762\u7aef\u7f51\u9875\u7684\u5bfc\u822a\u4f1a\u4f7f\u7528hover\u60ac\u505c\u51fa\u73b0\u4e0b\u62c9\u5217\u8868\uff0c\u4f46\u662f\u5728iPad\u4e0a\uff0c\u6216\u8005\u534e\u4e3aPad\uff0c\u6216\u8005\u5c0f\u7c73Pad\uff0c\u6216\u8005\u5176\u4ed6\u4ea7\u54c1\u7684\u89e6\u5c4f\u8bbe\u5907\u4e0a\uff0c\u8fd9\u4e2a\u91cd\u8981\u7684\u4e0b\u62c9\u5bfc\u822a\u6211\u4eec\u5c31\u5f88\u96be\u8ba9\u5b83\u51fa\u73b0\uff0c\u4e8e\u662f\u5c31\u4f1a\u5e26\u6765\u975e\u5e38\u7cdf\u7cd5\u7684\u4f53\u9a8c\u95ee\u9898\u3002<\/p>\n<p>\u6b64\u65f6\uff0chover\u7279\u5f81\u68c0\u6d4b\u5c31\u5f88\u6709\u7528\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>&lt;nav&gt;\r\n    &lt;a href&gt;\u4e3b\u5bfc\u822a&lt;\/a&gt;\r\n    &lt;div&gt;\r\n        &lt;a href&gt;\u4e0b\u62c9\u5bfc\u822a1&lt;\/a&gt;\r\n        &lt;a href&gt;\u4e0b\u62c9\u5bfc\u822a1&lt;\/a&gt;\r\n        &lt;a href&gt;\u4e0b\u62c9\u5bfc\u822a1&lt;\/a&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/nav&gt;<\/pre>\n<pre>\r\nnav div {\r\n    display: none;\r\n}\r\nnav:hover div {\r\n    display: block;\r\n}\r\n<span style=\"color:green;\">\/* \u5982\u679c\u8bbe\u5907\u4e0d\u652f\u6301hover\u60ac\u505c\uff0c\u6216hover\u60ac\u505c\u5f88\u4e0d\u65b9\u4fbf\uff0c\u4e0b\u62c9\u5217\u8868\u76f4\u63a5\u4fdd\u6301\u663e\u793a *\/<\/span>\r\n@media (any-hover: none) {\r\n  nav div {\r\n    display: block;\r\n  }\r\n}<\/pre>\n<p>\u8fd9\u6837\uff0c\u4f7f\u7528\u5927\u5c4f\u89e6\u78b0\u8bbe\u5907\u8bbf\u95ee\u6211\u4eec\u7f51\u7ad9\uff0c\u4e3b\u529f\u80fd\u5c31\u4f1a\u4f9d\u7136\u4fdd\u6301\u6b63\u5e38\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u66f4\u63a8\u8350\u7684\u65b9\u5f0f\u662f\u90fd\u50cf<a href=\"https:\/\/www.zhangxinxu.com\/sp\/lulu\/mockup\/\" rel=\"noopener\" target=\"_blank\">LuLu UI\u4e00\u6837<\/a>\uff0c\u6240\u6709\u7684hover\u4e0b\u62c9\u884c\u4e3a\u4e00\u5b9a\u4f1a\u515c\u5e95\u4e00\u4e2aclick\u4e0b\u62c9\u4e8b\u4ef6\u3002<\/p>\n<hr>\n<p>\u597d\u7684\uff0c\u5c31\u8fd9\u4e9b\uff0c\u672c\u6765\u4ee5\u4e3a\u662f\u4e2a\u77ed\u7bc7\uff0c\u7ed3\u679c\u6d0b\u6d0b\u6d12\u6d12\u8bf4\u4e86\u90a3\u4e48\u591a\u3002<\/p>\n<p>\u968f\u7740\u7269\u8054\u7f51\u65f6\u4ee3\u5230\u6765\uff0c\u672c\u6587\u8fd9\u51e0\u4e2a\u67e5\u8be2\u7279\u6027\u4f1a\u5f88\u6709\u7528\uff0c\u5f53\u7136\uff0c\u662f\u5bf9\u7528\u6237\u4f53\u9a8c\u91cd\u89c6\u7684\u5f00\u53d1\u5f88\u6709\u7528\u3002<\/p>\n<p>\u5982\u679c\u60a8\u89c9\u5f97\u672c\u6587\u5185\u5bb9\u6709\u6240\u6536\u83b7\u554a\uff0c\u6b22\u8fce\u5206\u4eab\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/emtion\/emoji\/1f618.svg\" width=\"20\" height=\"20\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=5474\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=5474<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/202001\/media-hover-pointer.png\" width=\"160\" height=\"105\" alt=\"media\u5a92\u4f53\u67e5\u8be2\u6587\u7ae0\u5934\u56fe\" class=\"alignright size-medium\" \/><\/p>\n<p>\u5927\u5c4f\u7684\u89e6\u5c4f\u8bbe\u5907\u8bbf\u95ee\u6211\u4eec\u7684\u4f20\u7edf\u7f51\u9875\u7684\u65f6\u5019\uff0cCSS any-hover any-pointer\u7b49\u5a92\u4f53\u67e5\u8be2\u53ef\u4ee5\u6781\u5927\u5730\u63d0\u5347\u6211\u4eec\u4ea7\u54c1\u7684\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1015,1540,1541,1271,278,498,1539,203],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/9216"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=9216"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/9216\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=9216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=9216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=9216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}