Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 将css类应用于";按钮“;内分区_Html_Css - Fatal编程技术网

Html 将css类应用于";按钮“;内分区

Html 将css类应用于";按钮“;内分区,html,css,Html,Css,我有一个包含如下按钮的div <div id="parentDiv"> <button id="myBtn" class="myclass">ADD ME</button> </div> 但令我惊讶的是,这门课并没有应用到巴顿身上。 请给我指出正确的方向。您可以使用CSS3选择器:禁用 #parentDiv button:disabled { color:#AAAAAA; } 将您的样式替换为此 #parentDiv butto

我有一个包含如下按钮的div

<div id="parentDiv">
    <button id="myBtn" class="myclass">ADD ME</button>
</div>
但令我惊讶的是,这门课并没有应用到巴顿身上。
请给我指出正确的方向。

您可以使用CSS3选择器:禁用

#parentDiv button:disabled
{
    color:#AAAAAA;
}

将您的样式替换为此

#parentDiv button:disabled
{
    color:#F00;
}

您需要添加属性选择器

#parentDiv button[disabled="disabled"] 
{
    color:red;
}
或者只是

#parentDiv button[disabled] 
{
    color:red;
}
#parentDiv按钮[disabled=“disabled”]{
颜色:红色;
}

加我

使用属性选择器
[attr]

#parentDiv button[disabled] {color: #aaa}

你能制作一个演示吗?我刚才编辑了这个问题,你能重温一下吗。为什么这个答案被降级了?是否不建议采用这种方法?这个答案中给出的解决方案非常有效。请评论。我真的不知道为什么!我希望主持人看到是谁干的。我的答案是加分的。为什么这个答案是加分的?不建议使用这种方法吗?请添加一些解释,说明此答案如何帮助OP解决当前问题
#parentDiv button[disabled] 
{
    color:red;
}
#parentDiv button[disabled] {color: #aaa}
#parentDiv button[disabled]
{
    color:red;
}