How to get rid of underline for Link component of React Router?

后端 未结 17 2414
独厮守ぢ
独厮守ぢ 2020-12-23 00:16

I have the following:

How do I get rid of the blue underline? The code is below:



        
相关标签:
17条回答
  • 2020-12-23 00:55

    What worked for me is this:

    <Link to="/" style={{boxShadow: "none"}}>
    
    0 讨论(0)
  • 2020-12-23 00:56

    There's also another way to properly remove the styling of the link. You have to give it style of textDecoration='inherit' and color='inherit' you can either add those as styling to the link tag like:

    <Link style={{ color: 'inherit', textDecoration: 'inherit'}}>
    

    or to make it more general just create a css class like:

    .text-link {
        color: inherit;
        text-decoration: inherit;
    }
    

    And then just <Link className='text-link'>

    0 讨论(0)
  • 2020-12-23 01:00

    //CSS

    .navigation_bar > ul > li {
          list-style: none;
          display: inline;
          margin: 2%;
        }
    
        .link {
          text-decoration: none;
        }
    

    //JSX

     <div className="navigation_bar">
                <ul key="nav">
                  <li>
                    <Link className="link" to="/">
                      Home
                    </Link>
                  </li>
                </ul>
              </div>
    
    0 讨论(0)
  • 2020-12-23 01:00

    To expand on @Grgur's answer, if you look in your inspector, you'll find that using Link components gives them the preset color value color: -webkit-link. You'll need to override this along with the textDecoration if you don't want it to look like a default hyperlink.

    0 讨论(0)
  • 2020-12-23 01:00
    style={{ backgroundImage: "none" }}
    

    Only this worked for me

    0 讨论(0)
提交回复
热议问题