模板:Click-switch:修订间差异

来自个人维基
跳转到导航 跳转到搜索
ChineseDolphin留言 | 贡献
无编辑摘要
ChineseDolphin留言 | 贡献
无编辑摘要
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
<includeonly>
<includeonly>
<div class="click-switch-container" style="display: inline-block; position: relative;">
<div style="display: inline-block; position: relative;">
   <!-- 添加了id必填检查 -->
   <input type="checkbox" id="click-switch-{{{id}}}"  
  {{#if: {{{id|}}}
        style="display: none;">
    | <input type="checkbox" id="click-switch-{{{id}}}" class="click-switch-checkbox" style="display: none;">
    | <strong style="color:red">错误:未提供id参数!</strong>
  }}
    
    
   <label for="click-switch-{{{id|}}}" style="cursor: pointer;">
   <label for="click-switch-{{{id}}}"  
     <span class="click-switch-text1">{{{text1|默认文本1}}}</span>
        style="cursor: pointer; display: block;"
     <span class="click-switch-text2">{{{text2|默认文本2}}}</span>
        onmousedown="return false;"> <!-- 防止文本选中 -->
   
    <!-- 初始可见文本 -->
     <span id="text1-{{{id}}}" style="display: inline;">
      {{{text1|默认文本1}}}
    </span>
   
    <!-- 初始隐藏文本 -->
     <span id="text2-{{{id}}}" style="display: none;">
      {{{text2|默认文本2}}}
    </span>
   </label>
   </label>
</div>
</div>
<style>
/* 初始状态隐藏text2 */
.click-switch-text2 { display: none; }
/* 选中状态显示text2,隐藏text1 */
#click-switch-{{{id|}}}:checked ~ .click-switch-text1 { display: none; }
#click-switch-{{{id|}}}:checked ~ .click-switch-text2 { display: inline; }
</style>
</includeonly>
</includeonly>

2025年8月5日 (二) 00:39的最新版本