使用:在css中的伪类之前插入特殊字符 [英] Insert special character using :before pseudo class in css

查看:344
本文介绍了使用:在css中的伪类之前插入特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在css中使用:before 伪类之前尝试插入一个特殊字符,但结果不是我所希望的。

使用:

  .read_more:before {
content:» ;
margin-right:6px;
}



我得到了我想要的字符,但是用Â 字符并使用:

  .read_more:before {
content:& raquo; ;
margin-right:6px;
}



我获得完整的& raquo; code>在html页面。



我可以想到几种方法来解决我的问题,但我想知道正确的语法如果我想要使用:之前伪类。



顺便说一下,我的doctype是:

 <!doctype html> 
< html lang =en>


解决方案

尝试指定< meta charset =utf-8> 。理想情况下,您要在服务器中设置此选项。


I was toying around with the :before pseudo class in css, trying to insert a special character but the result is not what I was hoping for.

Using:

.read_more:before {
    content: "»";
    margin-right: 6px;
}

I get the character I want, but with an  character before it and using:

.read_more:before {
    content: "&raquo;";
    margin-right: 6px;
}

I get the complete &raquo; on the html page.

I can think of a couple of ways to solve my problem, but I was wondering what the correct syntax would be if I wanted to use the :before pseudo class.

By the way, my doctype is:

<!doctype html>
<html lang="en">

解决方案

Try specifying <meta charset="utf-8">. Ideally you want to set this in the server.

这篇关于使用:在css中的伪类之前插入特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆