You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Anki闪卡提示功能改造:将点击显提示的文本替换为可切换显隐的样式按钮

Anki卡片提示按钮切换功能实现方案

1. 先将以下样式添加到Anki卡片模板的样式编辑区

/* 提示按钮基础样式 */
.button {
  border: none;
  color: white;
  padding: 12px 28px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 15px;
  margin: 6px 0;
  cursor: pointer;
  border-radius: 4px;
}
/* 绿色按钮样式 */
.button-hint {
  background-color: #4CAF50;
}

/* 提示内容显隐控制 */
#hint.hidden .payload {
  display: none;
}
#hint.shown .payload {
  display: block;
  margin-top: 10px;
  padding-left: 10px;
  border-left: 3px solid #4CAF50;
}

2. 替换你原有模板中的Hint相关代码为以下内容

{{#Hint}}
    <div id="hint" class="hidden">
        <button class="button button-hint">点击显示提示</button>
        <p class="payload">{{Hint}}</p>
    </div>
    <script>
        const hintContainer = document.getElementById('hint');
        const hintBtn = hintContainer.querySelector('button');
        hintBtn.addEventListener('click', function() {
            // 切换显示/隐藏状态
            hintContainer.classList.toggle('hidden');
            hintContainer.classList.toggle('shown');
            // 同步切换按钮文字,可按需删除
            this.textContent = hintContainer.classList.contains('shown') ? '点击隐藏提示' : '点击显示提示';
        });
    </script>
{{/Hint}}

修改说明

  • 原有的文本触发器已经替换为你要求样式的绿色按钮,你可以自行调整CSS中的尺寸、颜色参数适配你的卡片风格
  • 点击逻辑修改为状态循环切换,首次点击显示Hint内容,再次点击隐藏,可无限次切换
  • 额外添加了按钮文字同步切换、提示内容左侧标识的优化效果,不需要可以直接删除对应代码

内容的提问来源于stack exchange,提问作者HiSoKa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 22:54:04