Home  >  Article  >  Web Front-end  >  Is it possible to set styles for specific characters? _html/css_WEB-ITnose

Is it possible to set styles for specific characters? _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:49:251020browse

如题,想要针对页面中的特定字符设置样式,比如“@”或者“#”等,请教能否实现?如何实现?


回复讨论(解决方案)

不行,只有替换

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title> new document </title><style type="text/css">#hh span {color:#ff0000;}</style></head><body><div id="hh">#24567 #6576775	</div><script type="text/javascript">document.getElementById("hh").innerHTML = document.getElementById("hh").innerHTML.replace(/(#)/g,"<span>$1</span>")</script></body></html>

加上span:
66d0b0d84cb522108047a599bf006777@54bdf357c58b8a65c66d7c19c8e4d114
66d0b0d84cb522108047a599bf006777#54bdf357c58b8a65c66d7c19c8e4d114
在对类xx设置样式。

应该是不能实现这个功能,只能替换实现了。
谢啦。结贴

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn