html - 行文本行设置代码

标签 html css text line

我在设置我的 html 和 css 来模仿这张图片时遇到了问题, .关于如何设置它以使其线条、文本、线条都在同一垂直线上的任何提示?

最佳答案

使用 :before/:aftertop定位

编辑

查看最新更新 JSFiddle .

我补充说:

*,
*:before,
*:after
{
    position: relative;
}
.line:after
{
    position: absolute;
    top: 49px;
    left: 0;
    content: "";
    height: 1px;
    width: 100%;
    background-color: blue;
}
.line h3
{
    z-index: 1;
    display: block;
    width: 300px;
    margin-left: auto;
    margin-right: auto;
    background-color: #d1d1d1;
}

还有你的h3在你的 HTML 中我添加了 <div class="line"></div>

例如:

<div class="line">
    <h3><span style='color: #ff6c00;'>About</span> Me</h3>
</div>

再次 更改 top.line到您需要的数量,连同 background-color :)

关于html - 行文本行设置代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22077136/

相关文章:

html - CSS-HTML 视口(viewport)页面

html - 如何使 flexbox 元素的宽度和高度相等

css - 将样式注入(inject)测试页面

string - 在 Excel If 语句中返回数字和文本字符串

audio - 直接来自音频/转录的语音到文本(语音识别)

javascript - js 中的 if 语句无法正常工作

html - 我想做一个下拉菜单,但不知道怎么做

html - 按钮文本换行 : vertical alignment issue

css - Bootstrap 4 - 防止链接在导航栏上断行

c - 从文件读入数组并使用数组中的数字执行操作