我无法弄清楚如何使用 CSS 在元素上应用分割边框。
我想要达到的效果是这样的:

红线和灰线占元素宽度的百分比。最好,我想将此效果应用于使用单个类的元素。
编辑:对于那些要求代码示例的人:
<!-- spans width 100% -->
<div id="wrapper">
    <h1 class="title">DDOS Protection </h1>
</div>
    红色文字和红色下划线?为此有一些简单的 CSS。
<span style='color:red; border-bottom: 1px solid red;'>DDOS</span>
<span style='color:#999; border-bottom: 1px solid #999;'>Protection</span>
    好吧,假设您想使用单个类,并且没有看到您的确切标记,这将起作用:
<div class="message">
    <span>DDOS</span>
    <span>Protection</span>
</div>
然后你的 CSS 可能看起来像这样:
.message span {
    border-bottom: 1px solid #ccc;
    padding-bottom: 5px;
    color: #ccc;
}
    .message span:first-child {
        border-bottom-color: red;
        color: red;
        margin-right: 10px;
    }
这是一个jsFiddle 演示。
您也可以尝试使用:beforeand :after:
.line {
    background-color: #DDD;
    padding: 5px 10px;
    position: relative;
}
.line:before, .line:after {
    content: '';
    width: 10%;
    height: 2px;
    background-color: red;
    position: absolute;
    bottom: 0;
    left: 0;
}
.line:after {
    width: 90%;
    background-color: green;
    left: 10%;
}
    好的,我做了一个类似的,但被要求垂直,但现在正在改变渐变方向,这样它会帮助你
演示(在Chrome上工作,如果有人知道跨浏览器,请随时编辑,因为我使用的是旧浏览器所以无法测试)
CSS
div {
  font: 40px Arial;
  background: -webkit-gradient(linear, left top, right top, color-stop(0%,#ff0505), color-stop(50%,#ff0000), color-stop(50%,#000000), color-stop(100%,#000000));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}