<style type="text/css"> .box{ width: 750px; margin: auto; } .img-box{ width: 100%; position:relative; z-index:1; } .img-box img{ left:0; right:0; width:100%; z-index: -1; *zoom:1; } .img-box:before { content: ""; padding-bottom: 100%; width: 0.1px; /*必须要有数值,否则无法把高度撑起来*/ vertical-align: middle; } </style> <div class="box"> <div class="img-box"> {dede:field.body runphp=yes} global $cfg_basehost; $str = @me; $search = '/(<img.*?)width=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is'; $search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is'; $search2 = '#(<img.*?style=".*?)width: \d+px;([^"]*?.*?>)#i'; $search3 = '#(<img.*?style=".*?)height: \d+px;([^"]*?.*?>)#i'; $content = preg_replace($search,'$1$3',$str); $content = preg_replace($search1,'$1$3',$content); $content = preg_replace($search2,'$1$2',$content); $content = preg_replace($search3,'$1$2',$content); @me = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $content);//手机版图片使用绝对路径 {/dede:field.body} </div> </div> |
标签: