简体   繁体   English

CSS悬停按钮效果

[英]Css hover button effect

look at this fiddle JS FIDDLE When i hover( :hover ) background changes but when clicked ( :active ) box-shadow is not changed dont know why ? 看着这个小提琴JS FIDDLE当我的hover( :hoverbackground发生变化但单击( :activebox-shadow不变时,不知道为什么吗? This does not happen if another button does not change background on hover ! 如果另一个按钮没有更改悬停background ,则不会发生这种情况!

in this fiddle i want somehthing like combination of button 1 and button 2 在这个小提琴中,我想要类似button 1button 2组合

.white-button {
    background: #FFF;
    font-weight: normal;
    color: #3b3b3b;
    border: 1px solid #DDD;
    box-shadow: 0 0 2px #ccc;
    font-family: MV boli,Tahoma;
    margin: 5px;
    padding: 5px 10px 5px 10px;
    font-size: 15px;
}
.positive:enabled:hover {
    background: #99CD30;
    box-shadow: inset 2px -7px 11px rgba(80, 92, 51, 0.17)!important;
}
button:active {
    border-bottom-color: #999;
    box-shadow: inset 0 3px 3px rgba(0, 0, 0, .2);
}
.gray-button{
    background:#eee;
    padding:5px 10px;  
    border: 1px solid #999;
    border-bottom-color: #888;
}

For those who cant under stand! 对于那些谁不能站!

As you see there are 3 buttons on fiddle with name like lets say then button A,B and C respectively. 如您所见,小提琴上有3个按钮,它们的名字分别like按钮A,B and C

  • Now when i hover A i get a green background with an inset box-shadow . 现在,当我将鼠标悬停在A我得到一个绿色的背景,带有一个嵌入式的盒子阴影
  • When i hover B i get a green background with no inset shadow 当我将鼠标悬停在B我会看到绿色的背景,没有任何阴影
  • When i hover C i get nothing 当我悬停C什么也没得到

  • When i click A it remains same 当我单击A保持不变

  • when i click B an inset shadow is created 当我单击B ,会创建插图阴影
  • when i click C an an inset shadow is created 当我单击C ,将创建一个嵌入阴影

Now the button i want is D i want 现在我想要的按钮是D我想要

  • when i hover D i get ai get a green background with an inset 当我将鼠标悬停在D我会得到带有插图绿色背景
    box-shadow . 盒子阴影
  • when i click D an another inset shadow is created replacing previous one. 当我单击D将创建另一个插图阴影来替换先前的阴影

    but that does not happen dont know why ? 但这不会发生,不知道为什么吗?

I hope this is how you want it.. 我希望这就是你想要的。

http://jsfiddle.net/rahulrulez/M2f9F/3/ http://jsfiddle.net/rahulrulez/M2f9F/3/

I just played with properties that are !important 我只是玩过!important属性

.white-button {
background: #FFF;
font-weight: normal;
color: #3b3b3b;
border: 1px solid #DDD;
box-shadow: 0 0 2px #ccc;
font-family: MV boli,Tahoma;
margin: 5px;
padding: 5px 10px 5px 10px;
font-size: 15px;
}

.positive4:hover {
background: #99CD30;
box-shadow: inset 2px -7px 11px rgba(80, 92, 51, 0.17);
}

.positive4:active {
border-bottom-color: #999;
box-shadow: inset 0 3px 3px rgba(0, 0, 0, .2) !important;    
}

I hope this answers your question 我希望这回答了你的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM