查看: 2366|回复: 2
上一主题 下一主题 打印

dz7.2宽窄屏切换代码  [复制链接]

1、打开header模板找到
  1. </head>
复制代码
在下边加
  1. {eval $set_pwh = $_COOKIE["set_pwh"];}
复制代码
2、找到
  1. <div id="header">
复制代码
在上边加
  1. <a href="javascript:;" id="switchwidth" onclick="setcookie('set_pwh', 1, 999999);location.reload();" href="javascript:;" title="切换到宽版" class="switchwidth" {if $set_pwh == 1}style="display: none;"{/if}>
  2. 切换到宽版
  3. </a>
  4. <a href="javascript:;" id="snarrow" onclick="setcookie('set_pwh', 2, 999999);location.reload();" href="javascript:;" title="切换到窄版" class="snarrow" {if $set_pwh == 2}style="display: none;"{elseif $set_pwh == 1}style="display: block;"{else}style="display: none;"{/if}>
  5. 切换到窄版
  6. </a>
复制代码
3、找到
  1. <div class="wrap s_clear">
复制代码
修改为
  1. <div class="wrap s_clear" {if $set_pwh == 1}style="width: 93%;"{elseif $set_pwh == 2}style="width: 960px;"{/if} >
复制代码
修改方法大同小异,无非是找到对应的div,在style加入判断。

{if $set_pwh == 1}style="width: 93%;"{elseif $set_pwh == 2}style="width: 960px;"{/if}

比如要修改<div id="menu">

修改后既是<div id="menu" {if $set_pwh == 1}style="width: 93%;"{elseif $set_pwh == 2}style="width: 960px;"{/if}>

也就是说当$set_pwh变量等于1时,设置宽度为93%,若变量$set_pwh等于2时设置宽度为960px。

fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

TOP

测试

TOP