简体   繁体   English

为什么按钮只能在上半部分单击?

[英]Why is the buttons only clickable on the top half?

You can go to my test page here: https://socialstamp.me.uk/new/testpage.php 您可以在这里转到我的测试页面: https : //socialstamp.me.uk/new/testpage.php

The buttons to your left (under balance), only the top half of them can be clicked, bottom half doesn't work/click. 左边的按钮(处于平衡状态),只能单击它们的上半部分,下半部分不起作用/单击。 I've checked the CSS styling file and can't find anything, I've tried many solutions but nothing works. 我检查了CSS样式文件,找不到任何东西,我尝试了许多解决方案,但没有任何效果。

Button code: 按钮代码:

             <ul>
             <li id="l2"><a href="dashboard.php"></a></li>
             <li id="l3"><a href="trackingPanel.php"></a></li>
             <li id="l4"><a href="topup.php"></a></li>
             <li id="l5"><a href="contactform.php"></a></li>
             <li id="l6"><a href="accountSettings.php"></a></li>
             <li id="l7"><a href="apiHelp.php"></a></li>
             <li id="l8"><a href="referrals.php"></a></li>  
             </ul>

CSS: CSS:

#dashContainer .col-md-2 li {
display:block; 
height: 40px;
margin-bottom: 1px;
margin-left: 15px;
margin-right: 0;
}

#l2 {
   background-image: url('../img/menu/btn3.jpg');
}
#l2:hover {

background-image: url('../img/menu/btn3h.jpg');
}
#l2:active {

background-image: url('../img/menu/btn3h.jpg');
}

And so on for several buttons...

I'm surprised the buttons work at all. 我很惊讶这些按钮的作用。 While you define the size of the <li> , there is nothing defining the <a> and so in theory it should be of size 0, and therefore unclickable. 定义<li>的大小时,没有定义<a> ,因此理论上它的大小应为0,因此不可单击。

Make sure to apply your widths and heights to the link itself! 确保将您的宽度和高度应用于链接本身!

The issue is <li> tags have 41px height but <a> tags doesn't have any height except font-size. 问题是<li>标签的高度为41px,但是<a>标签的高度除了font-size之外没有其他高度。 By default <a> tags displayed inline so your clickable area just taking up space as <a> tags font size. 默认情况下, <a>标签以内inline显示,因此您的可点击区域仅以<a>标签字体大小占据空间。 There are too many ways to fix it. 有太多方法可以修复它。

First option : ( original answer ) 第一种选择:(原始答案)

By giving height and width to <a> tags as container: 通过给<a>标签作为容器高度和宽度:

 #dashContainer .col-md-2 li a {
    display:block;
    height:100%;
    width:100%;
 }

Second option : 第二种选择:

By adjusting <a> padding. 通过调整<a>填充。 No need give height to li tags if it is not important for UI . 如果对于UI不重要,则无需为li标签赋予高度。

#dashContainer .col-md-2 li {
   display:block; 
   /* height: 40px; */
   margin-bottom: 1px;
   margin-left: 15px;
   margin-right: 0;
}
#dashContainer .col-md-2 li a {
   padding:20px 0px;
}

Third option : 第三选择:

By giving height to <a> tags. 通过给<a>标签指定高度。

#dashContainer .col-md-2 li {
   display:block; 
   /* height: 40px; */
   margin-bottom: 1px;
   margin-left: 15px;
   margin-right: 0;
}
#dashContainer .col-md-2 li a {
   display:block;
   height:40px;
   line-height:40px; // for text vertical align
   width:100%;
}

如果您要在链接中添加CSS高度41px,则可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM