body{
font-family:"Arial","Lucida Grande", "Lucida Sans Unicode", Verdana, Helvetica, sans-serif;
font-size:12px;
}
p, h1, form, button{border:0; margin:0; padding:0;}
.spacer{clear:both; height:1px;}
/* ----------- My Form ----------- */
.myform{
margin:0 auto;
width:450px;
padding:14px;
}
/* ----------- regForm ----------- */
#regForm{
border:solid 2px #b7ddf2;
background:#A9D0F5;
}
#regForm h1 {
font-size:18px;
font-weight:bold;
margin-bottom:8px;
}
#regForm p{
font-size:11px;
color:#666666;
margin-bottom:20px;
border-bottom:solid 1px #b7ddf2;
padding-bottom:10px;
}
#regForm label{
display:block;
font-weight:bold;
text-align:right;
width:140px;
float:left;
}
#regForm .small{
color:#666666;
display:block;
font-size:11px;
font-weight:normal;
text-align:right;
width:140px;
}
#regForm input{
float:left;
font-size:100%;
padding:4px 2px;
border:solid 1px #2E9AFE;
width:200px;
margin:2px 0 20px 10px;
}
input:focus{
color:#848484;
font-weight:bold;
background-color:#FFC;
}
#regForm select{
float:left;
font-size:12px;
padding:4px 2px;
border:solid 1px #2E9AFE;
width:200px;
margin:2px 0 20px 10px;
}
#regForm button{
clear:both;
margin-left:150px;
width:150px;
height:50px;
background:#2E9AFE no-repeat;
text-align:center;
line-height:32px;
color:#FFFFFF;
font-size:20px;
font-weight:bold;
}
button:hover{
background-color:#FFC;
}
我的问题是为什么按钮背景的颜色没有改变?感谢。
fyi我的.html中有这一行:
<button type="submit">Sign-up</button>
答案 0 :(得分:6)
这是因为选择器#regForm button
比button:hover
更具有特定 - 请参阅:http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html以简化主题概述。
将:hover
选择器与id
选择器一起使用可解决此问题:
#regForm button:hover{
background-color:#FFC;
}
答案 1 :(得分:-1)
你必须使用像scartag建议的类或使用属性选择器:
input[type="button"]:hover {background-color:#FFC;}