Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.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伪类应用于外部CSS,常规类赢得';T_Html_Css - Fatal编程技术网

Html CSS伪类应用于外部CSS,常规类赢得';T

Html CSS伪类应用于外部CSS,常规类赢得';T,html,css,Html,Css,我试图将一些样式化的按钮组合在一起,并将我用来这样做的类保留在外部CSS表中。我的问题是,当我试图在HTML代码中引用该类时,伪类会应用,而标准类不会 我的HTML代码是 <body> <button class="buttonModifier"></button> <div class="buttonModifier"></div> </body> 然后在我的external.css表中,我有

我试图将一些样式化的按钮组合在一起,并将我用来这样做的类保留在外部CSS表中。我的问题是,当我试图在HTML代码中引用该类时,伪类会应用,而标准类不会

我的HTML代码是

<body>
      <button class="buttonModifier"></button>
      <div class="buttonModifier"></div>
</body>

然后在我的external.css表中,我有:

<style>

.buttonModifier{

    background-color:rgba(102,102,102,.6);  
    height:50px;
    width:50px;
    border-radius:3px;
    background-image:url(images/playerButton.png);




}

.buttonModifier:hover{

    background-color:rgba(102,102,102,1);   
    background-image:url(images/playerButton.png);

}

.buttonModifier:active{

    position:relative;
    top:1px;
    background-color:rgba(102,102,102,.6);  

}


</style>

.按钮修改器{
背景色:rgba(102102.6);
高度:50px;
宽度:50px;
边界半径:3px;
背景图片:url(images/playerButton.png);
}
.按钮修改器:悬停{
背景色:rgba(102102,1);
背景图片:url(images/playerButton.png);
}
.按钮修改器:活动{
位置:相对位置;
顶部:1px;
背景色:rgba(102102.6);
}

当我转到HTML页面时,class.buttonModifier不会应用于指定给该类的HTML元素,但当我将鼠标悬停在或单击按钮时,“:hover”和“:active”属性仍然适用。我认为我的.css工作表链接正确,因为伪类正在应用,而主类“.buttonModifier”却没有正确链接。

尝试添加button.buttonModifier,div.buttonModifier{//ur css}仅此一项就可以正常工作。@上图:当代码在同一文档中时,代码正常工作,但只有伪类从外部css应用。如果我必须把它直接放在我的HTML页面上,我可以做得很好,但我希望不必在每次创建新页面时都粘贴它,因此使用外部样式表。