css - 复杂的双文本下划线

标签 css border

所以我希望创建一种标题字体带有下划线的效果。我希望下划线拉伸(stretch)标题所在的 div 的宽度。但我希望文本正下方的下划线区域采用单独的颜色。所以在文本下面它应该是蓝色的,但是当下划线不再在文本下面时,它应该是灰色的。我在想一个双边框系统会起作用,但我不确定是否可以只用 CSS 来做到这一点......是吗?

最佳答案

这是另一个快速解决方案。将 500px 更改为您想要的任何值,可以是百分比。

HTML

<div class="blue">
    Header
</div>
<div class="grey">
    &nbsp;
</div>
<div class="clear">
</div>

CSS

.blue {
    padding-top: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid blue;
    float: left;
    overflow: hidden;
    position: absolute;
    z-index: 0;
}

.grey {
    padding-top: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid grey;
    float: left;
    width: 500px;
    overflow: hidden;
    position: absolute;
    z-index:-1;
}

.clear {
    clear: both;
}

示例:http://jsfiddle.net/UuYvv/

关于css - 复杂的双文本下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17758361/

相关文章:

javascript - Controller Action 完成时隐藏 div

php - Font Awesome 在 Laravel 5.8 管理面板中不起作用

css - 如何使 2 个元素适合页面高度?

xml - WPF - 带内容的边框模板

css - 我怎样才能制作这种边框?

html - Div 未与其他内容对齐但仍在包装器中

jquery - 单击单选按钮,突出显示 jQuery 中的 <p> 标记

html - 如何将这两个元素更紧密地结合在一起?

html - 我可以替换 <table border=1 >' with ` <table >` + css: ` table{...}` 吗?

html - css:图像位于父级 div 的边框上。如何在div中的图像上方制作文字?