jquery - <input type ="text"/>中的文字描边

标签 jquery css input outline stroke

我想在 <input type="text"/> 中使用文字描边我需要它是跨浏览器的(firefox、google chrome、safari、opera、IE7+)。

是否有任何方法可以做到这一点(CSS 2.1、jQuery...)?

最佳答案

我相信他说的是 css 属性 text-stroke (-webkit-text-stroke)。这仅在 webkit 浏览器中得到正确支持,因此在例如 Internet Explorer 中无法正确实现。但是,您可以使用 text-shadow 伪造它 can work in ie7+ .如果你必须在 ie 中包含它。参见 http://css-tricks.com/adding-stroke-to-web-text/

它看起来像:

.stroke_text {
    color: white;
    text-shadow:
          -1px -1px 0 #000,
          1px -1px 0 #000,
          -1px 1px 0 #000,
          1px 1px 0 #000;
}

或内联:

<input type='text' 
       style="color: white; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; width:200px; font-size:20px;" />

这种方法唯一真正的缺点是阴影只能是 1px 或开始看起来很滑稽,所以它不是 text-stroke 的完美复制。也就是说,您可能想要研究条件 css,其中支持它的浏览器使用文本笔画,而其他浏览器使用这种 hacky 方法。

关于jquery - &lt;input type ="text"/>中的文字描边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9213063/

相关文章:

c++ - 从 .dat 文件读取参数到 C++?

javascript - JQuery追加到变量元素

javascript - 粘性褪色导航栏即将出现

html - 在 Wordpress 中通过 CSS 将 Logo 居中

html - 提高一个 div 在另一个之上

在较低的 div 中带有 bg 图像的 HTML CSS 布局

jquery - DIV 位置固定,内部内容重叠

javascript - 如何过滤 JavaScript 对象以仅显示我需要的数据

C++ ifstream帮助(简单)

java - KeyListener 不响应键盘输入