html - 使用 CSS 显示不同的元素名称

标签 html css list

我无法控制 html,因为它托管在另一台服务器上。如果我想用css修改一些列表项,我应该怎么做?

例如

服务器端 html:

<ol>
<li>Coffee</li>
<li>Milk</li>
<li>Orange Juice</li>
<li>Chocolate Milk</li>
<li>Espresso with hot foamy milk</li>
<li>Espresso diluted with hot water</li>
</ol>

我想使用 CSS 将最后两项显示为“Cappuccino”和“Americano”。

谢谢。

最佳答案

实际上可以通过使用 :after 伪类来渲染它。但它真的很难看。仅当您没有其他选择时才这样做:

ol li:nth-child(5){
    color: #fff;           /* same color as the background to hide it */
    position:relative;
}    
ol li:nth-child(5):after{
    content: "Capuccino";
    display: block;
    color: #000;          /* your text color */
    position:absolute;
    top:0;
    left:0;
}

jsfiddle

关于html - 使用 CSS 显示不同的元素名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14447531/

相关文章:

html - CSS 无法作用于 div 类

html - CSS 订单/优先级帮助

html - 文本显示在“添加到购物车”按钮下方

javascript - 循环 div 内的每个 h2 标签

读取文件夹中的所有文件并将函数应用于每个数据框

python - 从列表中列出最常见的列表

javascript - .replaceWith jquery

jquery - 带有一些文本的 div 上的 Onclick 事件

css - 如何从 Bootstrap 菜单中删除阴影?

python - 如何跟踪列表中的所有字符串是否都存在特定字符串?