{"id":540,"date":"2015-04-06T21:10:32","date_gmt":"2015-04-06T13:10:32","guid":{"rendered":"http:\/\/www.baishitou.cn\/?p=540"},"modified":"2020-01-21T07:01:58","modified_gmt":"2020-01-20T23:01:58","slug":"divcss%e8%83%8c%e6%99%af%e5%9b%be%e7%89%87%e7%9a%84%e5%ae%9a%e4%bd%8d","status":"publish","type":"post","link":"https:\/\/www.baishitou.cn\/540.html","title":{"rendered":"div+css\u80cc\u666f\u56fe\u7247\u7684\u5b9a\u4f4d"},"content":{"rendered":"

\u6211\u4eec\u5728\u7814\u7a76\u5176\u4ed6\u7684\u7f51\u7ad9\u7684\u6837\u5f0f\u7684\u65f6\u5019\u7ecf\u5e38\u4f1a\u53d1\u73b0\u4e00\u79cd\u60c5\u51b5\uff0c\u5c31\u662f\u5728\u5f88\u591abackground\u5c5e\u6027\u91cc\u90fd\u8c03\u7528\u540c\u4e00\u5f20\u56fe\u7247\uff0c\u6765\u6ee1\u8db3\u7f51\u9875\u5404\u4e2a\u90e8\u5206\u7684\u4f7f\u7528\u3002\u6253\u5f00\u8fd9\u79cd\u56fe\u7247\u770b\u4e00\u4e0b\uff0c\u4f1a\u53d1\u73b0\u8fd9\u5f20\u56fe\u7247\u4e0a\u5305\u542b\u4e86\u5f88\u591a\u5c0f\u56fe\u7247\uff0c\u6bd4\u5982\uff1a<\/p>\n

\"html\/css\u6559\u7a0b\uff1a\u80cc\u666f\u56fe\u7247\u7684\u5b9a\u4f4d\u95ee\u9898\u8be6\u89e3\"<\/p>\n

\u53c8\u5982\uff1a<\/p>\n

\"html\/css\u6559\u7a0b\uff1a\u80cc\u666f\u56fe\u7247\u7684\u5b9a\u4f4d\u95ee\u9898\u8be6\u89e3\"<\/p>\n

\u8fd9\u4e9b\u5c0f\u56fe\u7247\u5c31\u662f\u6574\u56fe\u5206\u5272\u540e\u7684\u5404\u4e2a\u90e8\u5206\uff0c\u628a\u5404\u4e2a\u90e8\u5206\u653e\u5728\u4e00\u5f20\u56fe\u7247\u4e0a\uff0c\u800c\u4e0d\u662f\u662f\u5206\u522b\u5b58\u50a8\u6210\u5355\u72ec\u7684\u56fe\u7247\uff0c\u5176\u76ee\u7684\u6211\u4eec\u90fd\u77e5\u9053\uff0c\u5c31\u662f\u51cf\u5c11http\u8bf7\u6c42\u6b21\u6570\uff0c\u8282\u7701\u65f6\u95f4\u548c\u5e26\u5bbd<\/span>\u3002<\/p>\n

\u90a3\u4e48\u600e\u4e48\u6765\u5b9e\u73b0\u4e00\u5f20\u56fe\u7247\u5728\u4e0d\u540c\u7684\u5730\u65b9\u53ea\u663e\u793a\u5176\u4e2d\u7684\u4e00\u90e8\u5206\u5462\uff0c\u8fd9\u5c31\u7528\u5230\u4e86\u6211\u4eec\u4eca\u5929\u8981\u8bf4\u7684\u80cc\u666f<\/span>\u56fe\u7247\u7684\u5b9a\u4f4d\u95ee\u9898\u3002\u8fd9\u4e2a\u95ee\u9898\u76f8\u4fe1\u5f88\u591a\u4eba\u90fd\u90c1\u95f7\u8fc7\uff0c\u4e5f\u7ecf\u5e38\u6709\u670b\u53cb\u95ee\u6211\uff0c\u6240\u4ee5\u4eca\u5929\u5c31\u7cfb\u7edf\u7684\u8bf4\u4e00\u4e0b\uff1a<\/p>\n

\u6211\u4eec\u77e5\u9053\u5728\u7528\u56fe\u7247\u4f5c\u4e3a\u80cc\u666f\u7684\u65f6\u5019\uff0ccss\u8981\u8fd9\u6837\u5199<\/strong>\uff0c\u4ee5div\u5bb9\u5668\u4e3e\u4f8b\u5b50\uff0c\u4e5f\u53ef\u4ee5\u662fbody\u3001td\u3001p\u7b49\u7684\u80cc\u666f\uff0c\u9053\u7406\u4e00\u6837\u3002<\/em><\/p>\n\n\n\n
\u4ee3\u7801\uff1a<\/strong>div{ background:#FFF url(image) no-repeat fixed x y;}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u8fd9\u91cc\u7684background\u7684\u5c5e\u6027\u503c\u4f9d\u6b21\u4e3a\uff1a<\/p>\n

#FFF \u80cc\u666f\u8272\uff1a<\/span>\uff08\u989c\u8272\u503c\uff0c\u80cc\u666f\u56fe\u7247\u6ca1\u6709\u8986\u76d6\u7684\u5730\u65b9\uff0c\u6216\u8005\u6ca1\u6709\u80cc\u666f\u56fe\u7247\u65f6\u8868\u73b0\u7684\u80cc\u666f\u8272\uff09
\nimage \u80cc\u666f\u56fe\u7247\uff1a<\/span>\uff08\u8fd9\u91cc\u662f\u56fe\u7247\u7684\u5730\u5740\uff09
\nno-repeat \u662f\u5426\u91cd\u590d\uff1a<\/span>\uff08\u56fe\u7247\u5c0f\u4e8e\u5bb9\u5668\u7684\u5927\u5c0f\u65f6\uff0c\u9ed8\u8ba4\u4f1a\u91cd\u590d\u6392\u5217\u56fe\u7247\u4ee5\u586b\u6ee1\u5bb9\u5668\uff0cno-repeat\u8868\u793a\u4e0d\u91cd\u590d\uff0c\u53ea\u6709\u8fd9\u4e2a\u65f6\u5019\u540e\u9762\u7684\u5b9a\u4f4d\u5750\u6807\u624d\u6709\u7528\u3002\uff09
\nfixed \u80cc\u666f\u662f\u5426\u968f\u5bb9\u5668\u6eda\u52a8\uff1a<\/span>\uff08\u6709\u4e24\u4e2a\u53ef\u9009\u503c\uff0cscroll\u6eda\u52a8\uff0cfixed\u4e0d\u6eda\u52a8\uff0c\u9ed8\u8ba4\u662fscroll\uff09
\nx y \u80cc\u666f\u56fe\u50cf\u7684\u5b9a\u4f4d\uff1a<\/span>\uff08\u6ce8\u610f\uff0c\u53ea\u6709\u5728no-repeat\u4e0b\u5b9a\u4f4d\u624d\u6709\u610f\u4e49\u3002\u8fd9\u4e2a\u5c31\u662f\u4eca\u5929\u8981\u8bb2\u7684\u91cd\u70b9\uff09<\/p>\n

\u80cc\u666f\u56fe\u50cf\u5b9a\u4f4d\u4e2d\u6211\u4eec\u8981\u660e\u786e\u7684\u51e0\u70b9\uff1a<\/strong><\/p>\n

1\u3001\u4e24\u4e2a\u503c\u524d\u9762\u4e00\u4e2a\u662f\u6a2a\u5411\u7684\u5b9a\u4f4d\uff0c\u6211\u4eec\u79f0\u4e3ax\u8f74\u65b9\u5411\u5b9a\u4f4d\u3002\u540e\u9762\u4e00\u4e2a\u503c\u662f\u7eb5\u5411\u7684\u5b9a\u4f4d\uff0c\u6211\u4eec\u79f0\u4e3ay\u8f74\u65b9\u5411\u5b9a\u4f4d\u3002\u5982\u679c\u53ea\u6709\u4e00\u4e2a\u503c\uff0c\u90a3\u9ed8\u8ba4\u7684\u5c31\u662fx\u8f74\u65b9\u5411\uff0c\u8fd9\u65f6y\u8f74\u65b9\u5411\u5c31\u9ed8\u8ba4\u7684\u662f\u4e0a\u4e0b\u5c45\u4e2d\u5bf9\u9f50\uff0c\u4e5f\u5c31\u662fcenter\u3002
\n2\u3001\u5750\u6807\u8f74\u7684\u539f\u70b9\u5c31\u662f\u5bf9\u5e94\u5bb9\u5668\u7684\u5de6\u9876\u70b9<\/span>\u3002
\n3\u3001\u8fd9\u4e2a\u5750\u6807\u7684y\u8f74\u7bad\u5934\u671d\u4e0b\uff0c\u4e5f\u5c31\u662f\u53f3\u4e0b\u65b9\uff08\u5bb9\u5668\u5185\u90e8\uff09x y\u7684\u503c\u624d\u90fd\u4e3a\u6b63\u3002
\n4\u3001x y\u503c\u5206\u522b\u8868\u793a\u80cc\u666f\u56fe\u7247\u7684\u5de6\u9876\u70b9\u76f8\u5bf9\u4e8e\u5750\u6807\u539f\u70b9\uff08\u4e5f\u5c31\u662f\u5bb9\u5668\u7684\u5de6\u9876\u70b9\uff09\u7684\u503c\u3002
\n5\u3001x y\u7684\u503c\u53ef\u4ee5\u7528\u767e\u5206\u6bd4\u6216\u8005px\u6765\u8868\u793a\u3002
\n6\u3001x y\u4e5f\u53ef\u4ee5\u7528\u201cleft\u3001right\u3001top\u3001bottom\u3001center\u201d\u8fd9\u4e94\u4e2a\u5bf9\u9f50\u65b9\u5f0f\u6765\u8868\u793a\uff0c\u4f46\u6ce8\u610f\uff1a\u7528\u201cleft\u3001right\u3001top\u3001bottom\u3001center\u201d\u6765\u8868\u793a\u7684\u65f6\u5019\uff0c\u5e94\u7528\u7684\u662f\u5bf9\u9f50\u89c4\u5219\uff0c\u800c\u4e0d\u662f\u5750\u6807\u89c4\u5219<\/span>\u3002x\u4e3aleft\u662f\u8868\u793a\u56fe\u7247\u7684\u5de6\u8fb9\u548c\u5bb9\u5668\u7684\u5de6\u8fb9\u5bf9\u9f50\uff0c\u4e3aright\u7684\u65f6\u5019\u8868\u793a\u56fe\u7247\u7684\u53f3\u8fb9\u548c\u5bb9\u5668\u7684\u53f3\u8fb9\u5bf9\u5176\uff0cy\u4e3atop\u7684\u65f6\u5019\u8868\u793a\u56fe\u7247\u7684\u9876\u90e8\u548c\u5bb9\u5668\u7684\u9876\u90e8\u5bf9\u9f50\uff0c\u4e3abottom\u65f6\u8868\u793a\u56fe\u7247\u7684\u5e95\u90e8\u548c\u5bb9\u5668\u7684\u5e95\u90e8\u5bf9\u9f50\uff0cx y\u7b49\u4e8ecenter\u7684\u65f6\u5019\u8868\u793a\u5c45\u4e2d\u5bf9\u9f50\u3002
\n7\u3001x y\u7528\u767e\u5206\u6bd4\u6216\u8005px\u8868\u793a\u7684\u65f6\u5019\uff0c\u5176\u503c\u53ef\u4ee5\u4e3a\u8d1f\u6570\u3002\u6211\u4eec\u5e94\u7528\u5750\u6807\u89c4\u5219\u5c31\u5f88\u5bb9\u6613\u7406\u89e3\u8d1f\u6570\u8868\u793a\u7684\u610f\u4e49\uff0cx\u4e3a\u8d1f\u6570\u65f6\u5019\u8868\u793a\u56fe\u7247\u5de6\u9876\u70b9\u5728\u5bb9\u5668\u5de6\u9876\u70b9\u7684\u5de6\u4fa7\uff0cy\u4e3a\u8d1f\u6570\u65f6\u8868\u793a\u56fe\u7247\u7684\u5de6\u9876\u70b9\u5728\u5bb9\u5668\u7684\u5de6\u5b9a\u70b9\u7684\u4e0a\u65b9\u3002\u4e5f\u5c31\u662f\u5411\u5de6\u548c\u5411\u4e0a\u8d85\u51fa\u5bb9\u5668\u7684\u8303\u56f4\u3002<\/p>\n

\u4e0b\u9762\u6211\u7528\u51e0\u4e2a\u56fe\u793a\u6765\u8bf4\u660e\u4e00\u4e0b\u51e0\u79cd\u60c5\u51b5<\/strong>\uff0c\u84dd\u8272\u5757\u8868\u793a\u56fe\u7247\uff0c\u865a\u7ebf\u6846\u8868\u793a\u5bb9\u5668\uff08\u53ef\u4ee5div\uff0ctd\uff0c\u6216\u8005\u76f4\u63a5\u5c31\u662fbody\uff09\uff0c\u6ce8\u610f\u53ea\u6709\u80cc\u666f\u56fe\u7247\u5728\u5bb9\u5668\u5185\u6211\u4eec\u624d\u80fd\u770b\u89c1\uff0c\u6211\u7528\u767d\u8272\u8868\u793a\u53ef\u89c1\u90e8\u5206\uff0c\u800c\u4e14\u8d85\u51fa\u5bb9\u5668\u8303\u56f4\u7684\u662f\u770b\u4e0d\u89c1\u7684\uff0c\u6211\u7528\u7070\u8272\u8868\u793a\u3002\u5bb9\u5668\u7684\u5de6\u5b9a\u70b9\u7684\u5750\u6807\u5c31\u662f\uff080\uff0c0\uff09\u3002<\/p>\n

\"html\/css\u6559\u7a0b\uff1a\u80cc\u666f\u56fe\u7247\u7684\u5b9a\u4f4d\u95ee\u9898\u8be6\u89e3\"
\n\u7b2c\u4e00\u5f20\uff0c\u80cc\u666f\u56fe\u7247\u548c\u5bb9\u7684\u5de6\u4e0a\u5bf9\u9f50\uff0c0px 0px \u4e5f\u53ef\u4ee5\u5199\u6210left top<\/p>\n

\"html\/css\u6559\u7a0b\uff1a\u80cc\u666f\u56fe\u7247\u7684\u5b9a\u4f4d\u95ee\u9898\u8be6\u89e3\"
\n\u7b2c\u4e8c\u5f20\uff0c\u80cc\u666f\u56fe\u5728\u5bb9\u5668\u4e2d\u95f4\uff0c\u5b9a\u70b9\u5750\u6807\u4e3a\u6b63\u503c<\/p>\n

\"html\/css\u6559\u7a0b\uff1a\u80cc\u666f\u56fe\u7247\u7684\u5b9a\u4f4d\u95ee\u9898\u8be6\u89e3\"
\n\u7b2c\u4e09\u5f20\uff0c\u80cc\u666f\u56fe\u90e8\u5206\u5728\u5bb9\u5668\u5de6\u4e0a\uff0c\u5b9a\u70b9\u5750\u6807\u4e3a\u8d1f\u503c<\/p>\n

---------------------------------------------------------------------------<\/p>\n

\u5230\u6b64\u6211\u4eec\u53ef\u80fd\u5c31\u660e\u767d\u4e86\u5982\u4f55\u7528background\u91cc\u7684\u5b9a\u4f4d\u503c\u6765\u51c6\u786e\u5b9a\u4f4d\u4e00\u4e2a\u80cc\u666f\u56fe\u7247\uff0c\u8fd4\u56de\u53bb\u6211\u4eec\u770b\u4e00\u4e0b\u5f00\u59cb\u7684\u65f6\u5019\u4ecb\u7ecd\u7684\u4e24\u4e2a\u56fe\u7247\uff0c\u6211\u4eec\u5c31\u662f\u53ef\u4ee5\u7528\uff1a\u80cc\u666f\u5b9a\u4f4d\u548c\u5bb9\u5668\u5185\u624d\u53ef\u89c1\u8fd9\u4e24\u4e2a\u6027\u8d28\u6765\u968f\u610f\u7684\u8c03\u7528\u6574\u5f20\u56fe\u7247\u7684\u67d0\u4e00\u90e8\u5206\u3002<\/p>\n

\u4f46\u662f\u6211\u4eec\u4e3a\u4e86\u8c03\u7528\u65b9\u4fbf\uff0c\u5728\u6392\u5217\u8fd9\u4e9b\u5c0f\u56fe\u7247\u7684\u65f6\u5019\u8981\u8bb2\u7a76\u4e00\u70b9\u89c4\u5219\uff0c\u6bd4\u5982\uff1a\u5c0f\u56fe\u4e4b\u95f4\u7684\u8ddd\u79bb\u901a\u5e38\u662f\u8c03\u7528\u5c0f\u56fe\u7684\u5bb9\u5668\u7684\u5927\u5c0f\uff0c\u6216\u8005\u8ddd\u79bb\u66f4\u5927\u4e00\u70b9\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u907f\u514d\u5728\u5bb9\u5668\u5185\u663e\u793a\u51fa\u6211\u4eec\u4e0d\u613f\u610f\u663e\u793a\u7684\u56fe\u7247\uff01<\/p>\n

\u8865\u5145\u4e00\u70b9\uff0c\u5982\u679c\u5b9a\u4f4d\u7528\u7684\u662f\u767e\u5206\u6bd4\u8bdd\uff0c\u7b97\u6cd5\u6bd4\u8f83\u7279\u6b8a\u3002\u6211\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n\n\n\n
\n

\u4ee3\u7801\uff1a<\/strong><\/p>\n

background:#FFF url(image) no-repeat fixed 50% -30%;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u8fd9\u4e2a\u65f6\u5019\u56fe\u7247\u5e94\u8be5\u5728\u5bb9\u5668\u7684\u4ec0\u4e48\u4f4d\u7f6e\u5462,\u7b97\u6cd5\u516c\u5f0f\u5982\u4e0b\uff1a<\/p>\n

\u56fe\u7247\u5de6\u9876\u70b9\u8ddd\u5bb9\u5668\u5de6\u9876\u70b9\u7684\u5750\u6807\u4f4d\u7f6e\u4e3a
\nx\uff1a\uff08\u5bb9\u5668\u7684\u5bbd\u5ea6-\u56fe\u7247\u7684\u5bbd\u5ea6\uff09x50%
\ny\uff1a\uff08\u5bb9\u5668\u7684\u9ad8\u5ea6-\u56fe\u7247\u7684\u9ad8\u5ea6\uff09x\uff08-30%\uff09
\n\u5f97\u5230\u7684\u7ed3\u679c\u5e94\u7528\u5750\u6807\u6cd5\u5219\uff0c\u5dee\u503c\u5982\u679c\u4e3a\u8d1f\u6570\uff0c\u767e\u5206\u6bd4\u4e3a\u6b63\u90a3\u4e48\u8fd0\u7b97\u7ed3\u679c\u662f\u8d1f\u503c\u3002\u5982\u679c\u5dee\u503c\u4e3a\u8d1f\u6570\uff0c\u767e\u5206\u6bd4\u4e5f\u4e3a\u8d1f\u6570\uff0c\u90a3\u4e48\u8fd0\u7b97\u7ed3\u679c\u5c31\u662f\u6b63\u6570\u3002\u603b\u800c\u8a00\u4e4b\u5c31\u662f\u8fd9\u91cc\u7684\u8fd0\u7b97\u7b26\u5408\u8fd0\u7b97\u6cd5\u5219\u3002\u628a\u8fd0\u7b97\u7684\u7ed3\u679c\u5e26\u5165\u5750\u6807\u6cd5\u5219\u5c31\u80fd\u5f97\u5230\u56fe\u7247\u7684\u4f4d\u7f6e\u3002<\/p>\n

\u6bd4\u5982\uff1a\u5bb9\u5668\u662fwidth\uff1a600px\uff1bheight\uff1a600px\uff1b\u800c\u56fe\u7247\u662fwidth\uff1a200px\uff1bheight\uff1a200px\uff1b
\n\u6211\u4eec\u7528\u4e0a\u9762\u7684\u6837\u5f0f\uff0c\u53ef\u4ee5\u5f97\u5230\u56fe\u7247\u4f4d\u7f6e\u4e3a\uff1a
\nx\uff1a(600px-200px)*50%
\ny\uff1a(600px-200px)*(-30%)
\n\u5982\u4e0b\u56fe\uff1a<\/p>\n

\"html\/css\u6559\u7a0b\uff1a\u80cc\u666f\u56fe\u7247\u7684\u5b9a\u4f4d\u95ee\u9898\u8be6\u89e3\"<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6211\u4eec\u5728\u7814\u7a76\u5176\u4ed6\u7684\u7f51\u7ad9\u7684\u6837\u5f0f\u7684\u65f6\u5019\u7ecf\u5e38\u4f1a\u53d1\u73b0\u4e00\u79cd\u60c5\u51b5\uff0c\u5c31\u662f\u5728\u5f88\u591abackground\u5c5e\u6027\u91cc\u90fd\u8c03\u7528\u540c\u4e00\u5f20\u56fe\u7247\uff0c\u6765\u6ee1 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[27,164],"class_list":["post-540","post","type-post","status-publish","format-standard","hentry","category-wljs","tag-divcss","tag-164"],"_links":{"self":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/comments?post=540"}],"version-history":[{"count":0,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/540\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/media?parent=540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/categories?post=540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/tags?post=540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}