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

查看:25
本文介绍了处理 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天全站免登陆