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

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