Clickable icon with link

前端 未结 3 2007
醉话见心
醉话见心 2021-01-25 03:33

I have an icon list made of social media but they\'re only clickable on the letter of the icon, I want it to be clickable on any spot but I have to click on the \"F\" of faceboo

相关标签:
3条回答
  • 2021-01-25 04:18

    A possible workaround will be using css. anchor is inline element and it only wraps the icon. We need anchor to cover whole area in li

    using css

    ul li a{
        display:inline-block;
        width:100%;
        height:100%;
    }
    
    0 讨论(0)
  • 2021-01-25 04:27

    I would use inherit for de with and height of the li items. I used flexbox to align everything in the center. When hyperlinks are created for the other icons, you can remove the flexbox settings for li.

    li {
      width: 50px;
      height: 50px;
      background-color: pink;
      border: thin solid black;
      list-style: none;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    
    li>a {
      width: inherit;
      height: inherit;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
    <div class="leftside">
      <ul class="socialmediaicons">
        <li><a href="https://www.facebook.com/EnUnChasquido/"><i class="fa fa-facebook"></i></a></li>
        <li><i class="fa fa-instagram"></i></li>
        <li><i class="fa fa-twitter"></i></li>
        <li><i class="fa fa-youtube"></i></li>
      </ul>
    </div>

    0 讨论(0)
  • 2021-01-25 04:36

    li{
    	border:1px solid red;
    	display: inline-block;
    }
    .fa{
    	padding:15px;
    	padding-bottom: 15px;
    	padding-top:15px;
    
    }
    a{
    	display: block;
    }
    <html>
    <head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    </head>
    <body>
    	<div class="leftside">
        <ul class="socialmediaicons">
          <li><a href="https://www.facebook.com/EnUnChasquido/"><i class="fa fa-facebook"></i></a></li>
          <li><i class="fa fa-instagram"></i></li>
          <li><i class="fa fa-twitter"></i></li>
          <li><i class="fa fa-youtube"></i></li>
        </ul>
      </div>
    </body>
    </html>

       <html>
    <head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <style>
    li{
        border:1px solid red;
        display: inline-block;
    }
    .fa{
        padding:15px;
        padding-bottom: 15px;
        padding-top:15px;
    
    }
    a{
        display: block;
    }
    </style>
    </head>
    <body>
        <div class="leftside">
        <ul class="socialmediaicons">
          <li><a href="https://www.facebook.com/EnUnChasquido/"><i class="fa fa-facebook"></i></li></a>
          <li><i class="fa fa-instagram"></i></li>
          <li><i class="fa fa-twitter"></i></li>
          <li><i class="fa fa-youtube"></i></li>
        </ul>
      </div>
    </body>
    </html>
    
    0 讨论(0)
提交回复
热议问题