Har*_*ard 5 html css rendering google-chrome emoji
我有一个带有表情符号的页面,后跟一个空格和一些文本.例如,"朋友"(角色是"半身像",U + 1F465).在macOS上的Safari和Firefox中,它会根据预期在表情符号和以下文本之间进行渲染.
但是,在Chrome中,空格似乎不存在:
如果我删除空格,Chrome会将文字与表情符号重叠.看起来Chrome中呈现的表情符号宽度小于实际字符宽度.
有没有什么方法可以获得所需的外观(正常宽度空间)跨浏览器而不诉诸图像或图标字体?我试过搞乱一些CSS属性,比如text-rendering没有成功.
<style>
.friends {
font-family: Helvetica, Arial, sans-serif;
}
</style>
<span class="friends"> Friends</span>
Run Code Online (Sandbox Code Playgroud)
我有同样的问题,发现它只发生在非视网膜屏幕上.
为了解决这个问题,我们margin通过像这样的媒体查询来应用:
<span class="friends"><span class="emoji"></span> Friends</span>
<style>
@media
not screen and (min-device-pixel-ratio: 2),
not screen and (min-resolution: 192dpi) {
span.emoji {
margin-right: 5px;
}
}
</style>
Run Code Online (Sandbox Code Playgroud)
这是一个非常小的媒体查询.你可能应该使用更完整的一个,如/sf/answers/2210473121/.
我要做的是在包含表情符号的范围内添加另一个范围,让它.friends使用右边距,并且后面没有空格:
.friends {
font-family: Helvetica, Arial, sans-serif;
}
.friends span {
margin-right: 10px;
}Run Code Online (Sandbox Code Playgroud)
<span class="friends"><span></span>Friends</span>Run Code Online (Sandbox Code Playgroud)
这样你就不必担心空间渲染;)
希望这可以帮助!:)