简体   繁体   English

为什么在select2输入占位符上在手机上显示的字体真棒unicode图标变得混乱不堪?

[英]Why is font awesome unicode icon showing up messed up on mobile in select2 input placeholder?

I am trying to insert a placeholder icon into a select2 input field. 我正在尝试将一个占位符图标插入到select2输入字段中。

View on desktop: 在桌面上查看:

在此处输入图片说明

View on mobile: 在手机上查看:

在此处输入图片说明

Here is the code I use to integrate font awesome using unicode, to place the icon in a input field. 这是我使用unicode集成很棒的字体,将图标放置在输入字段中的代码。

jade (element in which I initialize the select2 on) 玉(我在其中初始化select2的元素)

#tags.icon(type="text", name="tags", placeholder= "   tags...")

and CSS 和CSS

.select2-input, #searchPosts
  font-family 'FontAwesome'

The weird thing is, when I click into the input field, type and then clear the typing, and click outside, the tag icon shows correctly. 奇怪的是,当我单击输入字段时,键入然后清除键入内容,然后单击外部,标记图标正确显示。 But it does not show correctly on load. 但是它在加载时无法正确显示。

Font Awesome and other icon sites often have compatibility issues across various different platforms. Font Awesome和其他图标网站通常在各种不同平台上都存在兼容性问题。 You should have back up options if unicode appears - such as a sprite. 如果出现unicode,则应具有备份选项,例如sprite。

Often mobile browser encoding is different to web version of the browser. 通常,移动浏览器的编码不同于浏览器的Web版本。

There are many ways to handle this and this article is a good place to start: http://www.creativebloq.com/app-design/icon-fonts-in-apps-21410734 有很多方法可以解决此问题,本文是一个不错的起点: http : //www.creativebloq.com/app-design/icon-fonts-in-apps-21410734

Without debugging it I'd say you're experiencing a z-index issue or an actual engine rendering mistake. 如果没有调试,我会说您遇到z-index问题或实际的引擎渲染错误。 Try setting the value later if you can. 如果可以,请稍后尝试设置该值。 If you know the placeholder text is achieved through a dom element addition, try increasing its z-index. 如果您知道占位符文本是通过添加dom元素实现的,请尝试增加其z-index。 Good Luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM