【发布时间】:2013-11-16 05:00:26
【问题描述】:
所以我正在做一些 wiki 编辑,遗憾的是没有启用 Javascript。因此,我需要 CSS 大师的帮助!
我知道您可以像这样添加自定义 HTML 属性:
<span id="some-id" custom_attr="no"></span>
您可以像这样使用custom_attr 设置元素的样式:
span[custom_attrib] { /* styling here */ }
现在,有没有办法在 CSS 中编辑 HTML 属性?
示例(当然不起作用..):
<!------------- CSS ------------>
<style>
.some-class {
/* Original code here */
}
.some-class[custom_attr = "yes"] {
/* Change code here */
}
#some-id:hover ~ .some-class[custom_attr = "no"] {
custom_attr : "yes";
}
</style>
<!------------- HTML ------------>
<html>
...
<span id="some-id">...</span>
<span class="some-class" custom_attr="no">...</span>
...
</html>
【问题讨论】:
-
不,你不能用 CSS 改变 attr
-
Now, is there a way to edit the HTML attribute inside the CSS?号
标签: html css pseudo-class