在CSS选择器中的元素ID中处理冒号 [英] Handling a colon in an element ID in a CSS selector

查看:555
本文介绍了在CSS选择器中的元素ID中处理冒号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSF将输入字段的ID设置为 search_form:expression 。我需要在该元素上指定一些样式,但冒号看起来像一个伪元素的开头到浏览器,所以它被标记为无效和被忽略。

JSF is setting the ID of an input field to search_form:expression. I need to specify some styling on that element, but that colon looks like the beginning of a pseudo-element to the browser so it gets marked invalid and ignored. Is there anyway to escape the colon or something?

input#search_form:expression {
  ///...
}


推荐答案

反斜杠:

input#search_form\:expression {  ///...}




  • 另请参阅 使用命名空间与CSS (MSDN)

  • 这篇关于在CSS选择器中的元素ID中处理冒号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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