html - 基线偏移和字母在可选文本上垂直对齐?

标签 html css

好的,所以我不确定去哪里找,因为它看起来非常具体,而且我对 CSS 的了解还不够多,不知道自己该怎么做。

我想在 HTML 和 CSS 中重现下图中的文本格式,以便可以选择和复制/粘贴文本,因为它应该被阅读。

我不知道如何让字母相对于一对中的另一个字母居中对齐(在它的正下方),并使基线偏移但仍然让文本位于一个段落或标题中。

感谢您的帮助! What I try to make

最佳答案

这可能就是您要实现的目标。当您选择并复制/粘贴时,它仍然是一个单词。

基本上是将每个字母包装成一个<i>左右,并设置 position:relative; top:15px;或类似的值(value)来转移其中的一些。

JSFiddle Demo

.e {
    background: silver;
    background-size: cover;
    text-align: center;
    padding: 30px;
}
.e i {
    font-style: normal;
    font-family: sans-serif;
    font-weight: bold;
    font-size: 50px;
    text-transform: uppercase;
    color: crimson;
    margin: 0 10px;
    display: inline;
}
.e i:nth-child(4), .e i:nth-child(6), .e i:nth-child(8) {
    text-transform: none;
}
.e i:nth-child(2), .e i:nth-child(4), .e i:nth-child(7), .e i:nth-child(9) {
    top: 15px;
    position: relative;
}
.e i:nth-child(4) {
    color: yellow;
}
.e i:nth-child(5):after {
    content: "\A";
    white-space: pre; 
}
<div class="e"><i>e</i><i>x</i><i>h</i><i>i</i><i>b</i><i>i</i><i>t</i><i>i</i><i>o</i><i>n</i></div>

关于html - 基线偏移和字母在可选文本上垂直对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30005527/

相关文章:

html - 960px 网格系统仍然是网页设计的标准吗?

html - CSS:文件之间的交互

html - 表比 Bootstrap 列容器宽

html - 使用分块编码有什么好处?

javascript - 如何显示弹出窗口

html - 防止背景重复

javascript - 使用 Gulp 为文件名添加时间戳

html - wbr 标记在 IE 中不起作用

不附加到 html 元素的 JavaScript 工具提示

html - 缩放时 CSS 对象显示在其他对象下方