{"id":2458,"date":"2018-01-31T14:29:02","date_gmt":"2018-01-31T06:29:02","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2458"},"modified":"2018-01-31T14:29:02","modified_gmt":"2018-01-31T06:29:02","slug":"%e8%a7%a3%e5%86%b3%e7%bd%91%e9%a1%b5%e5%ba%95%e9%83%a8%e7%b2%98%e8%bf%9estiky-footer%e5%b8%83%e5%b1%80%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2458","title":{"rendered":"\u89e3\u51b3\u7f51\u9875\u5e95\u90e8\u7c98\u8fde(Stiky footer)\u5e03\u5c40\u95ee\u9898"},"content":{"rendered":"<p>\n\t\u7f51\u9875\u5e95\u90e8\u7c98\u8fde\u95ee\u9898\u6bd4\u8f83\u5e38\u89c1\uff0c\u7fa4\u91cc\u5f88\u591a\u7f51\u53cb\u90fd\u95ee\u5230\u8fc7\u8fd9\u4e2a\u95ee\u9898\u3002\u6211\u8fd9\u91cc\u96c6\u4e2d\u5206\u6790\u4e00\u4e0b\u8be5\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6848\u3002\n<\/p>\n<p>\n\t\u5e95\u90e8\u7c98\u8fde\u5176\u5b9e\u5c31\u662f\u7f51\u9875footer\u90e8\u5206\u7684\u5e03\u5c40\u5b9a\u4f4d\u95ee\u9898\u3002\u5e38\u89c1\u7684\u5c31\u662f\u7f51\u9875\u5e95\u90e8\u7684\u4fe1\u606f\uff0c\u4f1a\u968f\u7740\u5185\u5bb9\u53d8\u5316\u3002\u5982\u679c\u5b9a\u4f4d\u4e0d\u5f53\uff0c\u4f1a\u5728\u5185\u5bb9\u8fc7\u591a\u65f6\uff0c\u5b83\u906e\u76d6\u4e86\u5185\u5bb9\uff1b\u5728\u5185\u5bb9\u8fc7\u5c11\u65f6\uff0c\u5b83\u53c8\u4f1a\u548c\u5185\u5bb9\u7c98\u8fde\u5728\u4e00\u8d77\u3002\u8fd9\u5c31\u662f\u8457\u540d\u7684\u7f51\u9875\u5e95\u90e8\u7c98\u8fde(stiky footer)\u5e03\u5c40\u95ee\u9898\u3002\u4eca\u5929\u6211\u63a8\u8350\u4f7f\u75284\u79cd\u65b9\u6cd5\u641e\u5b9a\u5b83\u3002\n<\/p>\n<p>\n\t\u5148\u770b\u4e00\u4e0b\u6211\u4eec\u4eca\u5929\u5b9e\u73b0\u540e\u7684\u6700\u7ec8\u6548\u679c\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u7f51\u9875\u5e95\u90e8\u7c98\u8fde(stiky footer)\u5e03\u5c40\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201801\/31\/1517379018_523304.gif\" style=\"width: 281px;height: 415px\" \/>\n<\/p>\n<h2>\n\t\u7edd\u5bf9\u5b9a\u4f4d<br \/>\n<\/h2>\n<p>\n\t\u6211\u4eec\u5148\u4f7f\u7528\u7edd\u5bf9\u5b9a\u4f4d\u6765\u89e3\u51b3\u8fd9\u7c7b\u95ee\u9898\u3002\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;style&gt;\r\nhtml,body{height:100%}\r\nbody{margin:0}\r\n.box{position:relative;background-color:lightblue;min-height:100%;}\r\n.content{padding-bottom:50px;}\r\n.sticky{position:absolute;background-color:lightgreen;width:100%;height:50px;bottom:0;}\r\n&lt;\/style&gt;\r\n&lt;div class=&quot;box&quot;&gt;\r\n  &lt;main class=&quot;content&quot;&gt;\r\n    \u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n    ...\r\n  &lt;\/main&gt;\r\n  &lt;footer class=&quot;sticky&quot;&gt;&lt;\/footer&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>\n\t\u5b9e\u73b0\u65b9\u6cd5\u662f\u5bf9(.sticky)footer\u8fdb\u884c\u7edd\u5bf9\u5b9a\u4f4d\uff0c\u5047\u8bbe\u9ad8\u5ea6\u4e3a50px\u3002\u5bf9\u7236\u7ea7(.box)\u8fdb\u884c\u76f8\u5bf9\u5b9a\u4f4d\uff0c\u5c06html\u3001body\u7684\u9ad8\u5ea6\u8bbe\u7f6e\u4e3a100%\uff0c\u7236\u7ea7(.box)\u7684\u6700\u5c0f\u9ad8\u5ea6\u8bbe\u7f6e\u4e3a100%\uff0c\u5c06(.content)\u5185\u5bb9\u90e8\u5206\u8bbe\u7f6epadding-bottom\u4e3afooter\u7684\u9ad8\u5ea6\uff0c\u537350px\u3002\n<\/p>\n<h2>\n\t\u6570\u5b66\u8868\u8fbe\u5f0fcalc<br \/>\n<\/h2>\n<p>\n\t\u6570\u5b66\u8868\u8fbe\u5f0fcalc()\u662fCSS\u4e2d\u7684\u51fd\u6570\uff0c\u4e3b\u8981\u7528\u4e8e\u6570\u5b66\u8fd0\u7b97\u3002\u4f7f\u7528calc()\u4e3a\u9875\u9762\u5143\u7d20\u5e03\u5c40\u63d0\u4f9b\u4e86\u4fbf\u5229\u548c\u65b0\u7684\u601d\u8def\u3002\u4e0b\u9762\u6211\u4eec\u4f7f\u7528\u6570\u5b66\u8868\u8fbe\u5f0fcalc\u6765\u89e3\u51b3\u5e95\u90e8\u7c98\u8fde(stiky footer)\u5e03\u5c40\u95ee\u9898\u3002\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;style&gt;\r\nbody{margin:0}\r\n.content{background-color:lightblue;min-height: calc(100vh - 50px)}\r\n.sticky{background-color:lightgreen;height:50px;}\r\n&lt;\/style&gt;\r\n&lt;div class=&quot;box&quot;&gt;\r\n  &lt;main class=&quot;content&quot;&gt;\r\n    \u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\t\u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n  &lt;\/main&gt;\r\n  &lt;footer class=&quot;sticky&quot;&gt;&lt;\/footer&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>\n\t\u7531\u4e8e\u7edd\u5bf9\u5b9a\u4f4d\u7684\u5b9e\u73b0\u8981\u6c42\u6700\u5c0f\u9ad8\u5ea6100%\u7684\u6548\u679c\uff0c\u7ed9html\u3001body\u90fd\u8bbe\u7f6e\u4e3a\u9ad8\u5ea6100%\uff0c\u4e0d\u5229\u4e8e\u4ee3\u7801\u6269\u5c55\u3002\u56e0\u6b64\u53ef\u4ee5\u4f7f\u7528100vh\u6765\u4ee3\u66ff100%\uff0c\u4ee3\u7801\u4f1a\u7b80\u6d01\u5f88\u591a\u3002\u5185\u5bb9\u90e8\u5206(.content)\u8bbe\u7f6e\u6700\u5c0f\u9ad8\u5ea6\u4e3acalc(100vh &#8211; 50px)\u3002\n<\/p>\n<h2>\n\tflex \u5e03\u5c40<br \/>\n<\/h2>\n<p>\n\t\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u5982\u679csticky\u7684\u5e95\u90e8\u9ad8\u5ea6\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u5219\u5185\u5bb9\u90e8\u5206\u7684\u4ee3\u7801\u4e5f\u9700\u8981\u8fdb\u884c\u76f8\u5e94\u5730\u8c03\u6574\u3002\u5982\u679c\u4f7f\u7528flex\uff0c\u5219\u53ef\u4ee5\u66f4\u52a0\u7075\u6d3b\u3002\u4e3a\u7236\u7ea7(.box)\u8bbe\u7f6eflex\u3001\u4e0a\u4e0b\u6392\u5217\u53ca\u6700\u5c0f\u9ad8\u5ea6\u4e3a100vh\uff0c\u4e3a\u5185\u5bb9\u90e8\u5206(.content)\u8bbe\u7f6eflex:1\u3002\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;style&gt;\r\nbody{margin:0}\r\n.box{display:flex;flex-flow:column;min-height:100vh;\r\nbackground-color:lightblue;}\r\n.content{flex:1;}\r\n.sticky{background-color:lightgreen;height:50px;}\r\n&lt;\/style&gt;<\/pre>\n<h2>\n\tgrid\u6805\u683c\u5e03\u5c40<br \/>\n<\/h2>\n<p>\n\tGrid\u5e03\u5c40\u65b9\u5f0f\u501f\u9274\u4e86\u5e73\u9762\u88c5\u5e27\u8bbe\u8ba1\u4e2d\u7684\u683c\u7ebf\u7cfb\u7edf\uff0c\u5c06\u683c\u7ebf\u8fd0\u7528\u5728\u5c4f\u5e55\u4e0a\uff0c\u800c\u4e0d\u518d\u662f\u5355\u4e00\u7684\u9759\u6001\u9875\u9762\uff0c\u53ef\u4ee5\u79f0\u4e4b\u4e3a\u771f\u6b63\u7684\u6805\u683c\u3002\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;style&gt;\r\nbody{margin:0}\r\n.box{display:grid;grid-template-rows:1fr 50px;min-height:100vh;}\r\n.content{background-color:lightblue;}\r\n.sticky{background-color:lightgreen;}\r\n&lt;\/style&gt;<\/pre>\n<p>\n\tgrid\u4f5c\u4e3a\u6700\u65b0\u5e03\u5c40\u65b9\u5f0f\u5b9e\u73b0\u8d77\u6765\u4ee3\u7801\u66f4\u52a0\u7b80\u6d01\u3002\n<\/p>\n<p>\n\t\u901a\u8fc7\u4e0a\u9762\u76844\u79cd\u5b9e\u73b0\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u51fa\u53ea\u8981\u8ba4\u771f\u5b66\u4e60\uff0c\u4efb\u4f55\u6280\u672f\u95ee\u9898\u90fd\u4e0d\u5728\u662f\u95ee\u9898\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2458\">\u89e3\u51b3\u7f51\u9875\u5e95\u90e8\u7c98\u8fde(Stiky footer)\u5e03\u5c40\u95ee\u9898<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u7f51\u9875\u5e95\u90e8\u7c98\u8fde\u95ee\u9898\u6bd4\u8f83\u5e38\u89c1\uff0c\u7fa4\u91cc\u5f88\u591a\u7f51\u53cb\u90fd\u95ee\u5230\u8fc7\u8fd9\u4e2a\u95ee\u9898\u3002\u6211\u8fd9\u91cc\u96c6\u4e2d\u5206\u6790\u4e00\u4e0b\u8be5\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6848\u3002 \u5e95\u90e8\u7c98\u8fde\u5176\u5b9e\u5c31\u662f [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[814,815,1119,48,1548],"class_list":["post-2458","post","type-post","status-publish","format-standard","hentry","category-html5","tag-css3","tag-flex","tag-gradient","tag-web","tag-1548"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2458"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2458\/revisions"}],"predecessor-version":[{"id":2459,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2458\/revisions\/2459"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}