admin管理员组文章数量:1391937
I'm making a menu and have one simple and stupid issue. The problem is: I have my <span>
elements inside a 'Menu' div
. With id '#menu'
. I've made a feature by which you can't accidentally click on the <a>
inside the <span>
through CSS visibility
. But now if you click the menu in space between white stripes, it won't act like a button.
So the question is: 'How to make this <div>
fully clickable?'
Here's the Fiddle.
Thanks in advance.
I'm making a menu and have one simple and stupid issue. The problem is: I have my <span>
elements inside a 'Menu' div
. With id '#menu'
. I've made a feature by which you can't accidentally click on the <a>
inside the <span>
through CSS visibility
. But now if you click the menu in space between white stripes, it won't act like a button.
So the question is: 'How to make this <div>
fully clickable?'
Here's the Fiddle.
Thanks in advance.
Share Improve this question edited Sep 17, 2016 at 12:41 Nitin9791 1,1441 gold badge14 silver badges18 bronze badges asked Sep 17, 2016 at 11:14 MaxelRusMaxelRus 3051 silver badge10 bronze badges 1- 2 Please post your code in the question, not just a link to it. – Bergi Commented Sep 17, 2016 at 14:52
2 Answers
Reset to default 11It can be simply do with width
property, just need to add a width to the menu div:
#menu {
-moz-user-select: none;
height: 40px;
margin: 50px;
position: absolute;
width: 40px; /* newly added */
}
Instead of keeping fixed width, we can also use the width to 100% which gives you more clickable area to collapse the menu
#menu {
position: absolute;
height: 40px;
width : 100%; /*newly added*/
margin: 50px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none
}
本文标签: javascriptHow to make the whole div clickableStack Overflow
版权声明:本文标题:javascript - How to make the whole div clickable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744732028a2622104.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论