Home > Web Front-end > HTML Tutorial > 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
Release: 2016-06-24 11:49:25
Original
1058 people have browsed it

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


回复讨论(解决方案)

不行,只有替换

<!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>
Copy after login

加上span:
@
#
在对类xx设置样式。

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template