【问题标题】:Why is the gradient text not being shown over the border fill? CSS为什么渐变文本没有显示在边框填充上? CSS
【发布时间】:2018-01-20 03:23:28
【问题描述】:

我使用了一个名为 http://css3buttongenerator.com/ 的网站并添加了一个文本渐变,但由于某种原因,我不确定它是否没有在页面上显示所有的 css 编码。

.button {
  background: linear-gradient(330deg, #e05252 0%, #99e052 25%, #52e0e0 50%, #9952e0 75%, #e05252 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-border-radius: 60;
  -moz-border-radius: 60;
  border-radius: 60px;
  font-family: Arial;
  font-size: 60px;
  background: #fff;
  padding: 10px 20px 10px 20px;
  text-decoration: none;
}

.button:hover {
  background: #000;
  text-decoration: none;
  background: linear-gradient(150deg, #e05252 0%, #99e052 25%, #52e0e0 50%, #9952e0 75%, #e05252 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
<div>
    <a class="button" href="course.html">Start</a>
</div>

【问题讨论】:

    标签: html css border gradient


    【解决方案1】:

    在您的 .button CSS 规则中,您覆盖了 background 属性。

    .button {
        /* first background */
        background: linear-gradient(330deg, #e05252 0%, #99e052 25%, #52e0e0 50%, #9952e0 75%, #e05252 100%); 
    
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        -webkit-border-radius: 60;
        -moz-border-radius: 60;
        border-radius: 60px;
        font-family: Arial;
        font-size: 60px;
    
        /* again background here*/
        background: #000;
    
        padding: 10px 20px 10px 20px;
        text-decoration: none;
    }
    

    删除第二个背景,它会起作用。

    【讨论】:

    • 所以我删除了第二个背景,但现在我在按钮上看到的只是文本,而不是文本和边框填充。还有什么我做错了吗?
    猜你喜欢
    • 1970-01-01
    • 2015-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-08
    相关资源
    最近更新 更多