答案 0 :(得分:2)
您可以向元素添加灰色border-bottom
,并将其与红色::after
伪元素部分重叠:
h1 {
border-bottom: 2px solid #E5E5E5;
}
h1:after {
content: '';
display: block;
border-bottom: 2px solid #EC1C24;
margin-bottom: -2px;
max-width: 200px;
}
<h1>Haberler</h1>
答案 1 :(得分:1)
.line {
background:gray;
position:relative;
height:2px;
}
.line:before {
content:'';
background:red;
width:30%;
height:2px;
position:absolute;
}
&#13;
<div class="line">
&#13;
答案 2 :(得分:0)
你可以将几个内联块元素与边框结合起来,但我不确定它是否值得(而不是使用图像):
div {
width: 120px;
height: 80px;
border-bottom: red 2px solid;
border-top: blue 2px solid;
display: inline-block;
}
#a {
width: 240px;
border-top: green 2px solid;
border-bottom: gray 2px solid
}
<div></div><div id="a"></div>
答案 3 :(得分:0)
hr {
margin: 0;
width: 100%;
height: 5px;
background-color: red;
border: 0;
}
hr:after {
content: '';
display: block;
border-bottom: 5px solid green;
max-width: 50%;
}
&#13;
<hr/>
&#13;
答案 4 :(得分:0)
<table border="0" cellspacing="0" cellpadding="0" style="width:100%;">
<tr style="height:2px;">
<td style="width:10%;background-color:#003b67;"></td>
<td style="width:90%;background-color: #4cff00;"></td>
</tr>
</table>
答案 5 :(得分:0)
@Thilina Dharmasena 原帖的扩展。
我使用他的实现创建了一个带有样式组件的进度条
<ProgressBar scroll='90%' />
const ProgressBar = styled.div`
background: #191923;
height: 4px;
position: relative;
&:before {
content: '';
background: #ffc107;
width: ${({ scroll }) => scroll};
height: 4px;
position: absolute;
}
`;