使链接填充可点击

时间:2015-07-02 17:54:21

标签: css hyperlink padding

我的下拉菜单链接周围的填充不可点击。当我将鼠标悬停在实际文本上时,它会改变颜色并变为可点击。如何使填充可点击?我读到我应该将它设计为内联块,但这不起作用。这也是我的第一篇文章,所以纠正我可能做错的无数事情。 CSS:

    body {
  font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  padding: 20px 50px 150px;
  font-size: 13px;
  text-align: left;
  background-position:center;
  background-image:url(sun.jpg);
}
a {
    display:inline-block;
    color: #6FF;
    text-decoration: none;
}
a:hover {
    color: #FFF;
}
ul {
    color:#6FF
  text-align: left;
  display: inline-block;
  margin: 0;
  padding: 1px 1px 1px 0;
  list-style: none;
}
ul li {
    color: purple;
  font: bold 12px/18px sans-serif;
  display: inline-block;
  margin-right: -10px;
  position: relative;
  padding: 20px 20px;
  background: #fff;
  cursor: pointer;
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
  -ms-transition: all 0.5s;
  -o-transition: all 0.5s;
  transition: all 0.5s;
}
ul li:hover {
  background: #555;
  color: #fff;
}
ul li ul {
  padding:0;
  position:absolute;
  top: 54px;
  left: 0;
  width: 150px;
  display: none;
  opacity: 0;
  visibility: hidden;
  -webkit-transiton: opacity 0.5s;
  -moz-transition: opacity 0.5s;
  -ms-transition: opacity 0.5s;
  -o-transition: opacity 0.5s;
  -transition: opacity 0.5s;
}
ul li ul li { 
  background-color:#555;
  color:#6FF; 
  display: block; 
}
ul li ul li:hover { background: #555; }
ul li:hover ul {
  display: block;
  opacity: 1;
  visibility: visible;
}

1 个答案:

答案 0 :(得分:3)

您应该将填充放入链接,而不是列表项,因为该链接是可点击的。



nuget pack project.csproj

    body {
        font-family:'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
        padding: 20px 50px 150px;
        font-size: 13px;
        text-align: left;
        background-position:center;
        background-image:url(sun.jpg);
    }
    a {
        padding: 20px 20px;
        display:inline-block;
        color: #6FF;
        text-decoration: none;
    }
    a:hover {
        color: #FFF;
    }
    ul {
        color:#6FF text-align: left;
        display: inline-block;
        margin: 0;
        padding: 1px 1px 1px 0;
        list-style: none;
    }
    ul li {
        color: purple;
        font: bold 12px/18px sans-serif;
        display: inline-block;
        margin-right: -10px;
        position: relative;
        background: #fff;
        cursor: pointer;
        -webkit-transition: all 0.5s;
        -moz-transition: all 0.5s;
        -ms-transition: all 0.5s;
        -o-transition: all 0.5s;
        transition: all 0.5s;
    }
    ul li:hover {
        background: #555;
        color: #fff;
    }
    ul li ul {
        padding:0;
        position:absolute;
        top: 54px;
        left: 0;
        width: 150px;
        display: none;
        opacity: 0;
        visibility: hidden;
        -webkit-transiton: opacity 0.5s;
        -moz-transition: opacity 0.5s;
        -ms-transition: opacity 0.5s;
        -o-transition: opacity 0.5s;
        -transition: opacity 0.5s;
    }
    ul li ul li {
        background-color:#555;
        color:#6FF;
        display: block;
    }
    ul li ul li:hover {
        background: #555;
    }
    ul li:hover ul {
        display: block;
        opacity: 1;
        visibility: visible;
    }