如何覆盖所有 link 效果?

How to override all link effects?

所以我正在尝试在 Shopify 上编辑我们商店的主题。我在 Asset.css.liquid 下做。

无论如何,我正在做的就是试图覆盖 link 悬停的效果(我假设它在主题上)。这是一个示例:https://codepen.io/jstn/pen/mdoOZJ

我在下面添加了以下 HTML 代码:

<a href="#" class="a1">Test</a>

以及 CSS 我添加了以下内容:

a.a1:hover{
        transition: none;
    }

当您将鼠标悬停在 link 上时,我想删除那些动画下划线。有办法吗?

在此先感谢您!我很感激!

body,html {
  margin: 0;
  font: bold 14px/1.4 'Open Sans', arial, sans-serif;
  background: #000;
}
ul { 
  margin: 150px auto 0; 
  padding: 0; 
  list-style: none; 
  display: table;
  width: 600px;
  text-align: center;
}
li { 
  display: table-cell; 
  position: relative; 
  padding: 15px 0;
}
a {
  color: #fff;
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 0.15em;
  
  display: inline-block;
  padding: 15px 20px;
  position: relative;
}
a:after {    
  background: none repeat scroll 0 0 transparent;
  bottom: 0;
  content: "";
  display: block;
  height: 2px;
  left: 50%;
  position: absolute;
  background: #fff;
  transition: width 0.3s ease 0s, left 0.3s ease 0s;
  width: 0;
}
a:hover:after { 
  width: 100%; 
  left: 0; 
}
@media screen and (max-height: 300px) {
    ul {
        margin-top: 40px;
    }
}
<ul>
  <li><a href="#">About</a></li>
  <li><a href="#">Portfolio</a></li>
  <li><a href="#">Blog</a></li>
  <li><a href="#">Contact</a></li>
</ul>

正在使用 a:after pseudo-element 创建下划线。要覆盖它,这就足够了:

a.a1:hover:after {
    display: none !important;
}

所以过渡是由于伪元素a:after上的过渡引起的。要更改此行为,只需在 a:after

上设置 transition: none;

我的意思是:

body,html {
  margin: 0;
  font: bold 14px/1.4 'Open Sans', arial, sans-serif;
  background: #000;
}
ul { 
  margin: 150px auto 0; 
  padding: 0; 
  list-style: none; 
  display: table;
  width: 600px;
  text-align: center;
}
li { 
  display: table-cell; 
  position: relative; 
  padding: 15px 0;
}
a {
  color: #fff;
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 0.15em;
  
  display: inline-block;
  padding: 15px 20px;
  position: relative;
}
a:after {    
  background: none repeat scroll 0 0 transparent;
  bottom: 0;
  content: "";
  display: inline-block;
  height: 2px;
  left: 50%;
  position: absolute;
  background: #fff;
  transition: none;
  width: 0;
}
a:hover:after { 
  width: 100%; 
  left: 0; 
}
@media screen and (max-height: 300px) {
    ul {
        margin-top: 40px;
    }
}
<ul>
  <li><a href="#">About</a></li>
  <li><a href="#">Portfolio</a></li>
  <li><a href="#">Blog</a></li>
  <li><a href="#">Contact</a></li>
</ul>