有一个脚本使用 Pandoc 生成输入 Markdown 文件的 HTML 表示形式。假设我对 HTML 表示的唯一控制是单个 CSS 文件的规范,我如何向 HTML 添加网站标题/ header ?
例如,假设我想添加一些非常简单的标题,有点像顶部的“ATLAS Briefings”栏,我该如何在 CSS 中而不是在页面的 HTML 中做到这一点?:
最佳答案
使用 ::after
或 ::before
伪元素中的 content
属性添加其他文本。
您还可以使用 absolute
和 top
/bottom
,left
/right 将其定位在其他位置
属性。
#site-title::after {
content: "Another Title";
/* If you need to position it, uncomment and modify the below values
position: absolute;
top: -5px;
left: 20px */
}
/* Add below rule if you need to position the additional text w.r.t to the current title */
#site-title{
position: relative;
}
输出:
关于html - 如何通过 CSS 将 header 添加到 HTML 页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32275095/