首页 > 解决方案 > 使用 HTML 字符作为背景

问题描述

我已经按照这个答案这个 html 字符作为背景图像。它工作得很好,但不能作为背景,HTML 字符位于文本之上。我已经尝试了几种可能性,但我认为有些东西超出了我的知识范围。

.number {position: relative;
    font-family: sans-serif;
    font-size: 18px;
    font-weight: bold;
    color: red;
}
.number::after {
    content: "\2617"; 
    color: blue; 
    margin-left: -1em; 
    font-size:30px;
}
<div class="number">
90
</div>

标签: htmlcssbackground

解决方案


使用z-index属性:

.background {
  position: absolute;
  z-index: -9999;
}

推荐阅读