我试图给链接下划线一个线性渐变,如下所示。
不幸的是它没有在这里显示颜色。问题是在我的浏览器中我只看到一种颜色,第一个渐变色……第二个有什么问题?制作这种下划线渐变的方法有误吗?
a {
background-image: linear-gradient(to right, rgba(57, 72, 255, 1) 100%, rgba(57, 213, 255, 1) 100%);
background-repeat: repeat-x;
background-size: 4px 4px;
background-position: 0 22px;
}
a:visited { color: #2a2a2a;
}
<a href=""> <p> Lorem Ipsum </p> </a>
好的,明白了。如果还有人想知道问题出在哪里:您必须将背景大小设置为 auto
。
最佳答案
a {
background: linear-gradient(to right,
rgba(57, 72, 255, 1),
rgba(57, 213, 255, 1)
);
background-position: bottom;
background-size: 100% 2px;
background-repeat: no-repeat;
text-decoration: none;
}
<a href="#"> Lorem Ipsum </a>
- 背景宽度必须为宽度的 100%,
- 位于底部,
- 并且不重复。
最重要的是我被删除了默认下划线。
关于html - 链接的线性渐变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50439833/