{"id":702,"date":"2016-01-08T15:01:09","date_gmt":"2016-01-08T07:01:09","guid":{"rendered":"http:\/\/www.baishitou.cn\/?p=702"},"modified":"2016-01-08T15:01:09","modified_gmt":"2016-01-08T07:01:09","slug":"css%e4%bb%8e%e5%a4%a7%e5%9b%be%e4%b8%ad%e6%8a%a0%e5%8f%96%e5%b0%8f%e5%9b%be%e5%ae%8c%e6%95%b4%e6%95%99%e7%a8%8bbackground-position%e5%ba%94%e7%94%a8","status":"publish","type":"post","link":"https:\/\/www.baishitou.cn\/702.html","title":{"rendered":"CSS\u4ece\u5927\u56fe\u4e2d\u62a0\u53d6\u5c0f\u56fe\u5b8c\u6574\u6559\u7a0b(background-position\u5e94\u7528)"},"content":{"rendered":"
\u76f8\u4fe1\u5f88\u591a\u559c\u6b22\u7814\u7a76\u7f51\u9875\u754c\u9762\u7684\u7ae5\u978b\u90fd\u9047\u5230\u8fc7\u4e00\u4e2a\u5947\u5999\u7684\u73b0\u8c61\uff1a\u7f51\u9875\u4e2d\u5f88\u591a\u56fe\u7247\u7d20\u6750\u88ab\u5408\u6210\u5728\u4e00\u5f20\u56fe\u7247\u4e0a\u3002<\/p>\n
\u8d77\u521d\u5c0f\u83dc\u6a21\u4eff\u7f51\u7ad9\u7684\u65f6\u5019\uff0c\u7ecf\u5e38\u9047\u5230\u8fd9\u4e2a\u73b0\u8c61\uff0c\u90a3\u65f6\u5019\u4e5f\u4e0d\u77e5\u9053\u8fd9\u65f6\u4ec0\u4e48\u6280\u672f\uff0c\u4eba\u5bb6\u7684\u6574\u5f20\u56fe\u7247\u7d20\u6750\u4e0d\u4f1a\u5229\u7528\uff0c\u53ea\u80fd\u7528ps\u5207\u56fe\uff0c\u5207\u6210\u5355\u4e2a\u7684\u518d\u7528\u3002\u3002\u3002<\/p>\n
\u5176\u5b9e\uff0c\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684\u6280\u672f\uff0c\u5c31\u662f\u56e0\u4e3a\u60f3\u8c61\u7684\u592a\u96be\u4e86\uff0c\u624d\u4e00\u76f4\u627e\u4e0d\u5230\u95ee\u9898\u7684\u5173\u952e\u3002<\/p>\n
\u8981\u60f3\u5b9e\u73b0CSS\u62a0\u56fe\uff0c\u53ea\u9700\u8981\u7528\u5230\u4e00\u4e2a\u5c5e\u6027\uff1abackground-position\u3002<\/p>\n
\u6309\u7167\u5b57\u9762\u7406\u89e3\uff0c\u8fd9\u4e2a\u5c5e\u6027\u5c31\u662f\u80cc\u666f\u5b9a\u4f4d\uff0c\u5148\u770b\u770bgoogle\u7f51\u7ad9\u7684\u7d20\u6750\u56fe\uff0c\u5982\u4e0b\uff1a<\/strong><\/p>\n \u5047\u5982\u5c0f\u83dc\u73b0\u5728\u60f3\u505a\u4e00\u4e2a+1\u6309\u94ae\uff0c\u5229\u7528\u4e0a\u8fb9\u7684\u7d20\u6750\u56fe\uff0c\u666e\u901a\u72b6\u6001\u663e\u793aA\u56fe\uff0c\u9f20\u6807\u79fb\u4e0a\u53bb\u663e\u793a\u540e\u663e\u793aB\u56fe\uff0c\u5b9e\u73b0\u8fd9\u4e48\u4e00\u4e2a\u52a8\u6001\u6548\u679c\u3002<\/p>\n \u6309\u94ae\u662f\u7528\u6765\u5b9e\u73b0\u529f\u80fd\u7684\uff0c\u4e00\u822c\u662f\u7528\u8d85\u94fe\u63a5\u54cd\u5e94\u5355\u51fb\u4e8b\u4ef6\uff0c\u4f46\u662f\u4e0d\u80fd\u628a\u80cc\u666f\u56fe\u76f4\u63a5\u52a0\u5728\u8d85\u94fe\u63a5\u4e0a\uff0c\u90a3\u6837\u5c31\u4e0d\u53eb\u6837\u5f0f\u5566\uff0c\u56e0\u4e3a\u8d85\u94fe\u63a5\u7684\u6587\u672c\u957f\u5ea6\u53d8\u5316\u65f6\uff0c\u6837\u5f0f\u4e5f\u53d8\u4e86\u3002<\/p>\n \u5730\u7403\u4eba\u4e00\u822c\u7684\u505a\u6cd5\u662f\uff0cdiv\u91cc\u8fb9\u5957\u4e00\u4e2a\u8d85\u94fe\u63a5\uff0c\u8d85\u94fe\u63a5\u8d1f\u8d23\u5b9e\u73b0\u529f\u80fd\uff0cdiv\u8d1f\u8d23\u88c5\u8f7d\u80cc\u666f\u56fe\u3002html\u7ed3\u6784\u5982\u4e0b\uff1a<\/strong><\/p>\n <\/p>\n \u6709\u4e86html\u9aa8\u67b6\uff0c\u63a5\u4e0b\u6765\u5c31\u8981\u5199css\u6837\u5f0f\u5566\u3002<\/p>\n \u5047\u5982\u6211\u4eec\u4ec0\u4e48\u90fd\u4e0d\u8003\u8651\uff0c\u76f4\u63a5\u628a\u6574\u5f20\u56fe\u7247\u8bbe\u4e3a\u80cc\u666f\uff0c\u6837\u5f0f\u5982\u4e0b\uff1a<\/strong><\/p>\n <\/p>\n \u6548\u679c\u5982\u56fe\uff1a<\/strong><\/p>\n div\u662f\u5757\u7ea7\u5143\u7d20\uff0c\u9ed8\u8ba4\u662f\u5360\u4e00\u884c\u7684\uff0c\u8fd9\u4e2a\u5148\u4e0d\u7528\u5173\u5fc3\uff0c\u4f46\u770b\u5230\u80cc\u666f\u56fe\u91cd\u590d\u4e86\uff0c\u8fd9\u663e\u7136\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\uff0c\u52a0\u4e0abackground-repeat:no-repeat;\u5c5e\u6027\uff0c\u6539\u8fdb\u6837\u5f0f\u5982\u4e0b\uff1a<\/strong><\/p>\n <\/p>\n \u8fd9\u6837\u5c31\u4e0d\u91cd\u590d\u4e86\u3002<\/p>\n div\u53ef\u4ee5\u7406\u89e3\u6210\u4e00\u4e2a\u77e9\u5f62\u6846\uff0c\u5b83\u7684\u5de6\u4e0a\u89d2\u662f\u9876\u70b9\uff0c\u80cc\u666f\u56fe\u7247\u7684\u9876\u70b9\u4e5f\u662f\u5de6\u4e0a\u89d2\uff0cdiv\u52a0\u8f7d\u80cc\u666f\u56fe\u65f6\uff0c\u4f1a\u628a\u4e24\u4e2a\u9876\u70b9\u91cd\u5408\uff0c\u9876\u70b9\u7684\u5750\u6807\u662f(0,0)\u3002\u4e0d\u7406\u89e3\u7684\u770b\u56fe\uff0c\u5f88\u7b80\u5355\u7684\u3002\u3002\u3002<\/p>\n <\/p>\n +1\u7684\u5c0f\u56fe\u7247\u6df7\u6742\u5728\u5927\u56fe\u4e2d\uff0c\u60f3\u63d0\u53d6\u51fa\u6765\uff0c\u9700\u8981\u7528background-position\u5c5e\u6027\uff0c\u8fd9\u4e2a\u5c5e\u6027\u76f8\u5f53\u4e8e\u5927\u56fe\u7247\u4e0d\u52a8\uff0c\u628adiv\u7684\u9876\u70b9\u8fdb\u884c\u79fb\u52a8\uff0c\u79fb\u52a8\u5230\u76ee\u6807\u5c0f\u56fe\u7684\u9876\u70b9\u4f4d\u7f6e\uff0c\u5982\u4e0b\u56fe\uff1a<\/strong><\/p>\n \u8fd9\u6837\u4e00\u6765\uff0cdiv\u4e2d\u663e\u793a\u7684\u5c31\u662f\u5c0f\u56fe\u4e86\uff0c\u4f46\u662f\uff0c\u663e\u793a\u7684\u8fd8\u4e0d\u4ec5\u4ec5\u662f\u5c0f\u56fe\uff0c\u800c\u662f\u56fe\u4e2d\u9634\u5f71\u90e8\u5206\uff0c\u600e\u4e48\u529e\u5462\uff1f\u8bbe\u7f6e\u4e00\u4e0b<\/strong>div<\/strong>\u7684\u5bbd\u3001\u9ad8\uff0c\u8ba9\u5b83\u548c\u5c0f\u56fe\u7684\u5bbd\u3001\u9ad8\u4e00\u6837<\/strong>\u5c31\u53ef\u4ee5\u4e86\u5457\uff01\uff01<\/p>\n \u518d\u6765\u770b\u770bbackground-position\u5c5e\u6027\uff0c\u5b83\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u662f\u6c34\u5e73\u65b9\u5411\u79fb\u52a8\u7684\u50cf\u7d20\u3001\u7ad6\u76f4\u65b9\u5411\u79fb\u52a8\u7684\u50cf\u7d20\uff0c\u90fd\u7528\u8d1f\u6570\u8868\u793a<\/strong>\u3002\u5927\u56fe\u4e0d\u52a8\uff0cdiv\u79fb\u52a8\uff0c\u4e5f\u53ea\u80fd\u662f\u5411\u53f3\u3001\u5411\u4e0b\u79fb\u52a8\uff0c\u53ea\u8981\u8bb0\u4f4f\u8fd9\u4e24\u4e2a\u65b9\u5411\u79fb\u52a8\u7684\u50cf\u7d20\u90fd\u7528\u8d1f\u6570\u8868\u793a\u5c31\u884c\u4e86\uff01<\/p>\n \u56e0\u6b64\uff0c\u53ea\u8981\u627e\u5230\u5c0f\u56fe\u76f8\u5bf9\u4e8e\u5927\u56fe\u5de6\u4e0a\u89d2\u9876\u70b9\u7684\u6c34\u5e73\u79fb\u52a8\u50cf\u7d20\u3001\u7ad6\u76f4\u79fb\u52a8\u50cf\u7d20\u5c31\u53ef\u4ee5\u4e86\u3002\u5c0f\u83dc\u4e5f\u4e0d\u7528\u4ec0\u4e48\u4e13\u4e1a\u5de5\u5177\uff0c\u7528\u622a\u56fe\u5c31\u5f88\u65b9\u4fbf\uff0c\u4ece\u5927\u56fe\u5de6\u4e0a\u89d2\u9876\u70b9\u5f00\u59cb\u622a\uff0c\u5230\u5c0f\u56fe\u9876\u70b9\u90a3\u505c\u4e0b\u6765\uff0c\u4e00\u770b\u50cf\u7d20\u5c31\u5dee\u4e0d\u591a\u4e86\uff0c\u7136\u540e\u518d\u8c03\u8bd5\u8c03\u8bd5\uff0c\u57fa\u672c\u5c31\u641e\u5b9a\u3002<\/p>\n \u5728\u672c\u4f8b\u4e2d\uff0cA\u5c0f\u56fe\u7684\u4f4d\u79fb\u662f\uff1a-25px -374px\uff0cA\u5c0f\u56fe\u5c3a\u5bf8\u662f\uff1a24px 16px\u3002\u56e0\u6b64\uff0ccss\u6837\u5f0f\u5982\u4e0b\uff1a<\/strong><\/p>\n<\/p>\n
<\/p>\n
1 <div class=\"btn\">\r\n2 <a href=\"http:\/\/www.kpdown.com\">+1<\/a>\r\n3 <\/div><\/pre>\n<\/div>\n
1 .btn{\r\n2 background:url(bg.png);\r\n3 }<\/pre>\n<\/div>\n
<\/p>\n
1 .btn{\r\n2 background:url(bg.png);\r\n3 background-repeat:no-repeat;\r\n4 }<\/pre>\n<\/div>\n
<\/p>\n
<\/p>\n