dsgrgaz321973284 2019-04-28 06:11
浏览 103
已采纳

如果用户单击按钮出现的区域,则HTML隐藏按钮仍可单击

I created a makeshift hide/show menu in HTML/CSS using a checkbox, it works great to hide and show text and links, but I have a section where I'd like to show a button when the "checkbox" is clicked. At first it looks great, the button is hidden and when the user clicks the checkbox, a button appears below it. My problem that I'm having is that if the user clicks below the checkbox where the button appears before the button actually appears, they can still trigger the button. Any idea?

<td>
<label class="collapsible">
<input type="checkbox" />
<span class="collapser">Edit</span>
<span class="arrow">&gt;</span>
<div class="collapsed">
<form method="post">
<input type="hidden" id="pwd" name="deleteid" value='. $value["id"] . '>
<button onclick="return confirm_delete();" type="submit" name="DelBidSubmit" class="btn btn-default">Delete</button>
<script type="text/javascript">
    function confirm_delete() {
        return confirm("Are you sure you wish to delete that?");
    }
</script></form></div></label></td>

Heres my CSS code just in case

.collapsible {
  display: block;
  margin-bottom: 1rem;
}
.collapsible input {
  position: absolute;
  left: -9999px;
}
.collapsible input:focus ~ .collapser {
  border-color: grey;
}
.collapsible .collapser {
  cursor: pointer;
  border: 1px transparent dotted;

}

.collapsible .arrow {
  float: right;
  margin-left: 0.5em;
  display: inline-block;
  transform: rotate(90deg);
  transition: transform 0.25s ease-out;
}
.collapsible input:checked ~ .arrow,
.collapsible input:checked ~ .collapser .arrow {
  transform: rotate(270deg);
}
.collapsible .collapsed {
  font-size: 0;
  margin: 0;
  opacity: 0;
  padding: 0;
  /* fade out, then shrink */
  transition: opacity 0.25s, margin 0.5s 0.25s, font-size 0.5s 0.25s, padding 0.5s 0.25s;
}
.collapsible input:checked ~ .collapsed {
  font-size: 12px;
  opacity: 1;
  height: auto;
  padding: 5px 0;
  /* grow, then fade in */
  transition: margin 0.25s, padding 0.25s, font-size 0.25s, opacity 0.5s 0.25s;
}
  • 写回答

1条回答 默认 最新

  • douhuang1852 2019-04-28 06:20
    关注

    I think you must use {display: none}; and {display: block} to handle show/hide actions. Remove opacity:0 and opacity:1 from your styles and replace display:none and display:block styles.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器