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 QTableWidget重绘程序崩溃
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含
  • ¥15 麒麟V10桌面版SP1如何配置bonding