css怎么做某个字高亮

2025-04-15 19:56:57

1、新建html文件在本地IIS目录下,使用记事本新建一个html文件,命名为css高亮特效.html。如图:

css怎么做某个字高亮

2、写入基本元素使用记事本打开,在html文件中,写入html文件的基本构成元素:<!DOCTYPE 茑霁酌绡html><html> <head> <meta charset="UTF-8"> </head> <body> </body></html>如图:

css怎么做某个字高亮

3、插入文字内容在<body>标签中写入三段文字,用来对比高亮特效:<p id="p1">This paragragh doesn't use ::selection</p> <p id="p2">This paragragh uses ::selection,highlight color is yellow.</p> <p id="p3">This paragragh uses ::selection,highlight color is blue.</p>如图:

css怎么做某个字高亮

4、写入c衡痕贤伎ss特效在<head>标签中定义css样式代码:<style> #p2::selection { 艘早祓胂 background: yellow; } #p3::selection { background: blue; } </style>如图:

css怎么做某个字高亮

5、浏览特效使用浏览器打开文件,按ctrl+a全选页面,查看效果。如图:

css怎么做某个字高亮

6、默认高亮重新输入一个标签<font>,并在css代码区内重新定义样式:<font>我本来就是高亮的</font>font{ background:yellow; font-size:68px; color:white; }如图:

css怎么做某个字高亮

7、对比特效打开网页文件,这次不要使用全选功能,查看高亮特效。如图:

css怎么做某个字高亮
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢