gpt4 book ai didi

html - 缩短在 CSS 中使用的 html ID

转载 作者:太空宇宙 更新时间:2023-11-04 13:53:02 24 4
gpt4 key购买 nike

有什么方法可以像这样缩短 HTML 元素标签:

<input id=ctl00_ctl32_g_9bd32d9e_a30e_48f8_af0e_4c4b7e8ba1f5_createSuggestion>

在 CSS 中,这样我就不必引用整个内容,只需像这样使用它的 createSuggestion 部分:

input createSuggestion{
margin-left:10%;
}

例如,在生成 SQL 查询时,有时会使用“like %createSuggestion”。有任何想法吗?

最佳答案

您可以通过 attribute selector 实现如下:

input[id$="createSuggestion"] {
margin-left: 10%;
}

6.3.2. Substring matching attribute selectors

[att$=val] Represents an element with the att attribute whose value ends with the suffix "val". If "val" is the empty string then the selector does not represent anything.

关于html - 缩短在 CSS 中使用的 html ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26491388/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com