你必须div在你的后面放置一个textarea,然后根据它的文本设置样式。
注意事项:
textarea background-color为透明以查看您的highlighter颜色。highlighter必须与您的样式和文本内容相同textarea才能将其span放在正确的位置。highlighter文本设置为与背景相同的颜色,否则您会看到<b>效果,对于span.html :
<div class="highlighter">some text <span>highlighted</span> some text</div>
<textarea>some text highlighted some text</textarea>
Run Code Online (Sandbox Code Playgroud)
css :
.highlighter, textarea {
width: 400px;
height: 300px;
font-size: 10pt;
font-family: 'verdana';
}
.highlighter {
position: absolute;
padding: 1px;
margin-left: 1px;
color: white;
}
.highlighter span {
background: red;
color: red;
}
textarea {
position: relative;
background-color: transparent;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12114 次 |
| 最近记录: |