{"id":1472,"date":"2017-05-21T17:01:55","date_gmt":"2017-05-21T09:01:55","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=1472"},"modified":"2017-05-21T17:01:55","modified_gmt":"2017-05-21T09:01:55","slug":"htmlhtml5-%e8%ae%be%e7%bd%aeimg%e5%9b%be%e7%89%87%e8%87%aa%e9%80%82%e5%ba%94div%e5%ae%b9%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=1472","title":{"rendered":"HTML\/HTML5 \u8bbe\u7f6eimg(\u56fe\u7247)\u81ea\u9002\u5e94div(\u5bb9\u5668)"},"content":{"rendered":"<p>\n\t\u6211\u7684\u53e6\u4e00\u7f51\u7ad9 <a href=\"http:\/\/www.codedq.net\" name=\"CODE\u5927\u5168\" target=\"_blank\" title=\"CODE\u5927\u5168\">CODE\u5927\u5168<\/a>\uff0c\u4f7f\u7528\u7684 <a href=\"http:\/\/www.bootcss.com\/\" target=\"_blank\">bootstrap<\/a> \u642d\u5efa\u7684\u3002\u4f46\u662f\u5bf9\u4e8e<a href=\"http:\/\/www.codedq.net\" name=\"\u4e2a\u4eba\u535a\u5ba2\" target=\"_blank\" title=\"\u4e2a\u4eba\u535a\u5ba2\">\u535a\u5ba2<\/a>\u4e2d\u5f15\u5165\u7684\u56fe\u7247\u603b\u662f\u4e0d\u80fd\u968f\u7740\u79fb\u52a8\u7aef\u7684\u9002\u914d\u8fdb\u884c\u53cb\u597d\u7684\u5c55\u793a\u3002\u4eca\u5929\u67e5\u9605\u4e86\u4e00\u4e9b\u76f8\u5173\u8d44\u6599\uff0c\u8fdb\u884c\u4e86\u4f18\u5316\uff0c\u5728\u8fd9\u91cc\u505a\u4e2a\u603b\u7ed3\uff01\n<\/p>\n<p>\n\t\u505a\u6cd5\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u8bbe\u7f6e\u5bf9\u5e94\u56fe\u7247\u7684width\u548chtight\u7684\u5177\u4f53\u6570\u503c\u5c31\u53ef\u4ee5\u4e86\u3002\u770b\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a\n<\/p>\n<pre class=\"brush:css;\">\r\nimg{\r\n width:auto;\r\n height:auto;\r\n max-width:100%;\r\n max-height:100%;\r\n}<\/pre>\n<p>\n\t\u8fd9\u6837\u8bbe\u7f6e\u56fe\u7247\u7684\u8bdd\uff0c\u53ef\u4ee5\u4f7f\u56fe\u7247\u5728\u6307\u5b9a\u7684\u7a7a\u95f4\u5185\u7f29\u653e\u30024\u884c\u7684\u610f\u601d\u662f\uff1a\n<\/p>\n<ul>\n<li>\n\t\twidth:auto;\u56fe\u7247\u7684\u5bbd\u5ea6\u81ea\u5df1\u9002\u5e94(\u56fe\u7247\u6709\u591a\u5bbd\u5c31\u663e\u793a\u591a\u5bbd)\n\t<\/li>\n<li>\n\t\theight:auto;\u56fe\u7247\u7684\u9ad8\u5ea6\u81ea\u5df1\u9002\u5e94(\u56fe\u7247\u6709\u591a\u9ad8\u5c31\u663e\u793a\u591a\u9ad8)\n\t<\/li>\n<li>\n\t\twidth:auto;\u548cheight:auto;\u4e00\u8d77\u4f7f\u7528\u5c31\u4ee3\u8868\u7740\u663e\u793a\u56fe\u7247\u7684\u539f\u59cb\u5c3a\u5bf8(\u53ef\u4ee5\u7406\u89e3\u4e3a\u6ca1\u6709\u4ec0\u4e48\u4f5c\u7528)\n\t<\/li>\n<li>\n\t\tmax-width:100%;\u56fe\u7247\u7684\u5bbd\u5ea6\u4e0d\u80fd\u8d85\u8fc7\u56fe\u7247\u6240\u5728\u7684\u7a7a\u95f4\u7684\u5bbd\u5ea6\n\t<\/li>\n<li>\n\t\tmax-height:100%;\u56fe\u7247\u7684\u9ad8\u5ea6\u4e0d\u80fd\u8d85\u8fc7\u56fe\u7247\u6240\u5728\u7684\u7a7a\u95f4\u7684\u9ad8\u5ea6\n\t<\/li>\n<li>\n\t\tmax-width:100%;max-height:100%;\u4e00\u8d77\u4f7f\u7528\u5c31\u4ee3\u8868\u8fd9\u56fe\u7247\u7684\u5bbd\u9ad8\u5c3a\u5bf8\u6700\u5927\u4e0d\u80fd\u8d85\u8fc7\u5b83\u6240\u5728\u7684\u7a7a\u95f4\u7684\u5bbd\u9ad8\u3002\n\t<\/li>\n<\/ul>\n<p>\n\t<a href=\"http:\/\/www.xttblog.com\/?p=1472\" name=\"max-width \u5c5e\u6027\u8be6\u89e3\" target=\"_blank\" title=\"max-width \u5c5e\u6027\u8be6\u89e3\">max-width<\/a> \u548c <a href=\"http:\/\/www.xttblog.com\/?p=1472\" name=\"max-height\" target=\"_blank\" title=\"max-height\">max-height<\/a>\uff0c\u4f18\u5148\u5bf9max-width\u8fdb\u884c\u7f29\u653e\uff0c\u5f53\u56fe\u7247\u5728max-width\u7f29\u653e\u540e\u7684\u5c3a\u5bf8\u4ecd\u7136\u8d85\u51fa\u5bb9\u5668\u5927\u5c0f\u65f6\u3002max-height\u5c31\u53d1\u6325\u4e86\u4f5c\u7528\uff1a\u5bf9\u56fe\u7247\u518d\u6b21\u8fdb\u884c\u7f29\u653e\uff01\u4e3e\u4f8b\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;div style=&quot;width:50px;height:40px&quot;&gt;\r\n  &lt;img src=&quot;a.jpg&quot;&gt;\r\n  &lt;!--\u8fd9\u91cc\u6211\u4eec\u5047\u5982\u56fe\u7247\u7684\u5b9e\u9645\u5c3a\u5bf8\u662f320X320--&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>\n\t\u56fe\u7247\u88ab\u7f29\u653e\u540e\u5728div\u7684\u5c3a\u5bf8\u662f\uff1a<br \/>\n\twidth:50px;\uff08\u56e0\u4e3a\u56fe\u7247\u7684width:100%\uff09<br \/>\n\theight:50px\uff08\u8fd9\u91ccheight\u662f\u6709width:100%\u88ab\u7f29\u653e\u540e\u7684\u5c3a\u5bf8\u3002\uff09<br \/>\n\t\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u8fd9\u4e2a50px\u7684\u9ad8\u5ea6\u4ecd\u7136\u8d85\u51fa\u4e86div\u768440px\u7684\u9ad8\u5ea6,\u4e0d\u7b26\u5408max-height<br \/>\n\t\u8fd9\u4e2a\u65f6\u5019\uff0cmax-height:100%;\u5c31\u4f1a\u53d1\u6325\u4f5c\u7528\uff0c<br \/>\n\t\u5728max-height:100%;\u7684\u4f5c\u7528\u4e0b\uff0c\u56fe\u7247\u88ab\u7f29\u653e\u540e\u5728div\u7684\u5c3a\u5bf8\u662f\uff1a<br \/>\n\twidth:40px;<br \/>\n\theight:40px;<br \/>\n\t\u8fd9\u4e2a\u5c3a\u5bf8\u7b26\u5408max-height\u548cmax-width<br \/>\n\t\u6240\u4ee5\uff0c\u5f53div\u5728\u4e0d\u65ad\u53d8\u5316\u65f6\uff0c\u56fe\u7247\u5728div\u4e2d\u4e5f\u4f1a\u8ddf\u7740\u5e03\u65ad\u53d1\u751f\u53d8\u5316\uff0c<br \/>\n\t\u8fd9\u91cc\u4e0d\u4ecb\u610f\u7ed9\u56fe\u7247\u8bbe\u7f6ewidth:100%;height:100%\uff1b\u4f1a\u9020\u6210\u56fe\u7247\u53d8\u5f62\u3002\n<\/p>\n<h2>\n\t\u5b8c\u6574\u4f8b\u5b50<br \/>\n<\/h2>\n<pre class=\"brush:xml;\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;meta charset=&quot;utf-8&quot;&gt;\r\n        &lt;title&gt;&lt;\/title&gt;\r\n        &lt;style&gt;\r\n            img{\r\n                width: auto;\r\n                height:auto;\r\n                max-height: 100%;\r\n                max-width: 100%;\r\n            }\r\n        &lt;\/style&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;div id=&quot;div&quot; style=&quot;width: 50px;height: 50px;&quot;&gt;\r\n            &lt;img src=&quot;..\/5100036_080649087294_2.jpg&quot; \/&gt;\r\n        &lt;\/div&gt;\r\n        &lt;script&gt;\r\n            window.onload=function(){\r\n                setInterval(function(){move();},1000);\r\n            }\r\n             \r\n            function move(){\r\n                var _width=document.getElementById(&#039;div&#039;).style.width.replace(&#039;px&#039;,&#039;&#039;);\r\n                if(parseInt(_width)&gt;400){\r\n                    document.getElementById(&#039;div&#039;).style.width=parseInt(_width)-5+&#039;px&#039;;\r\n                    document.getElementById(&#039;div&#039;).style.height=parseInt(_width)-5+&#039;px&#039;;\r\n                }else{\r\n                    document.getElementById(&#039;div&#039;).style.width=parseInt(_width)+5+&#039;px&#039;;\r\n                    document.getElementById(&#039;div&#039;).style.height=parseInt(_width)+5+&#039;px&#039;;\r\n                }\r\n            }\r\n        &lt;\/script&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\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=1472\">HTML\/HTML5 \u8bbe\u7f6eimg(\u56fe\u7247)\u81ea\u9002\u5e94div(\u5bb9\u5668)<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6211\u7684\u53e6\u4e00\u7f51\u7ad9 CODE\u5927\u5168\uff0c\u4f7f\u7528\u7684 bootstrap \u642d\u5efa\u7684\u3002\u4f46\u662f\u5bf9\u4e8e\u535a\u5ba2\u4e2d\u5f15\u5165\u7684\u56fe\u7247\u603b\u662f\u4e0d\u80fd\u968f\u7740\u79fb\u52a8\u7aef\u7684\u9002 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[1201,1198,1197,1200,1199],"class_list":["post-1472","post","type-post","status-publish","format-standard","hentry","category-html5","tag-img","tag-max-height","tag-max-width","tag-1200","tag-1199"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1472","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=1472"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1472\/revisions"}],"predecessor-version":[{"id":1473,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1472\/revisions\/1473"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}