我有以下几点:
如何去掉蓝色下划线? 代码如下:
<Link to="first"><MenuItem style={{paddingLeft: 13, textDecoration: 'none'}}> Team 1 </MenuItem></Link>
MenuItem组件来自http://www.material-ui.com/#/components/menu
我有以下几点:
如何去掉蓝色下划线? 代码如下:
<Link to="first"><MenuItem style={{paddingLeft: 13, textDecoration: 'none'}}> Team 1 </MenuItem></Link>
MenuItem组件来自http://www.material-ui.com/#/components/menu
当前回答
核心方法在app。css(或对应版本)中
a{
text-decoration: none;
}
这防止下划线为所有<a>标签,这是这个问题的根本原因
其他回答
<Link to="/page">
<Box sx={{ display: 'inline-block' }}>
<PLink variant="primary">Page</PLink>
</Box>
</Link>
在某些情况下,当在Gatsby <Link>组件中使用另一个组件时,在内部组件周围添加带有display: 'inline-block'的div,可以防止下划线(在示例中为'Page')。
CSS解决方案也用于React
只在Link(React Router)标签中添加className/class。(最重要的部分!!在链接标签中添加ClassName,而不是其他标签。) 在css文件中添加text-decoration: none。
Nav.js
<Link to="/" className="link" >
Get Started
</Link>
Nav.css
.link{
text-decoration: none;
}
为了扩展@Grgur的答案,如果你在检查器中查看,你会发现使用Link组件会给它们预设的颜色值color: -webkit-link。如果你不想让它看起来像一个默认的超链接,你需要覆盖这个textDecoration。
<Link />标签在呈现时基本上是<a>标签,所以你可以只写
a { text-decoration: none; }
这对我来说很有效:) 祝你好运
我解决了一个像你这样的问题。我试着在firefox中检查元素。 我将向你们展示一些结果:
这只是我检查过的元素。“Link”组件将被转换为“a”标签,“to”道具将被转换为“href”属性:
当我点击:hov和选项:hover,这里是结果:
如你所见:悬停有文字装饰:下划线。我只添加到我的css文件:
a:hover {
text-decoration: none;
}
问题就解决了。但我也在一些其他类(比如你:D)设置了text-decoration: none,这可能会产生一些效果(我猜)。