简体   繁体   English

CSS3中的按钮不可单击

[英]Button in CSS3 not clickable

I want to make some fancy social buttons with Font Awesome , CSS3 and lists in HTML. 我想用Font Awesome ,CSS3和HTML中的列表制作一些精美的社交按钮。 It should look like this. 它应该看起来像这样。 But now it is not possible to click on the anchor (a-tag). 但是现在无法单击锚点(a标签)。

How can I accomplish this? 我该怎么做?

 ul { list-style: outside none none; } ul li { display: block; float: left; background-color: #099; margin-right: 10px; padding: 10px 0px; text-align: center; width: 40px; opacity: 0.2; transition: all 0.2s ease-in-out 0s; } li::before { color: #FFF; font-size: 35px; } ul li a { color: transparent; font: 0px/0 a; white-space: nowrap; } ul li:hover { opacity: 1; } 
 <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/> <ul id="menu-social" class="menu"> <li id="menu-item-googleplus" class="fa fa-google-plus menu-item menu-item-googleplus"> <a href="#">Google+</a> </li> <li id="menu-item-facebook" class="fa fa-facebook menu-item menu-item-facebook"> <a href="#">Facebook</a> </li> </ul> 

Add position relative to the li elements and then stretch the anchor. 相对于li元素添加位置,然后拉伸锚点。

ul li {
    display: block;
    float: left;
    background-color: #099;
    margin-right: 10px;
    padding: 10px 0px;
    text-align: center;
    width: 40px;
    opacity: 0.2;
    transition: all 0.2s ease-in-out 0s;

    /* Add position */
    position:relative;
    }

ul li a {
    color: transparent;
    font: 0px/0 a;
    white-space: nowrap;

   /* Stretch a element */
   position: absolute;
   left:0;
   top:0;
   width:100%;
   height: 100%;
}

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

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