【问题标题】:button - single button with hover and click effect with icon按钮 - 带有悬停和单击效果的单个按钮,带有图标
【发布时间】:2016-06-01 09:50:33
【问题描述】:

我怎样才能为单个按钮做两种效果。您可以从下面的链接中获取示例。

我只想在“悬停并单击”时更改图标信封效果

  1. 悬停图标应该改变它的效果,你可以在页面底部看到绿色的效果。

  2. 当点击同一个按钮时,图标应该会改变它的效果,就像购物车移动的按钮一样。

jsfiddler 将不胜感激。

感谢提醒

example link

【问题讨论】:

  • 你试过什么?您链接到一个页面,所有这些效果都可以作为演示使用。尝试将两者结合起来,如果遇到任何问题,请提出问题
  • 我试过..但它不工作..到目前为止尝试了下面.btn-7b:hover span { /*overflow: hidden;*/ -webkit-transform: translateY(300%); -moz 变换:翻译 Y(300%); -ms-transform: translateY(300%);变换:translateY(300%); } .btn-7b: 之前 { 左: 0;最高:-100%; } .btn-7b:hover:before { top: 0; }
  • 你能摆弄一下吗?

标签: javascript jquery html css animation


【解决方案1】:

您可以使用此代码

$("button").mousedown(function(){
    $(this).css("background-color", "#B8A3C1");
});
$(document).mouseup(function(){
    $("button").css("background-color", "#823aa0");
});
button {
    width: 250px;
    height: 70px;
    position: relative;
    background: #823aa0;
    border: none;   
    color: #fff;
    overflow: hidden;
    transition: all 1s; 
    outline: none;
}

button:before,
button:after {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0px;
    transition: all 0.3s;
    line-height: 65px;
}

button:before {
    content: "\2663";     
    top: -70px;
    font-size: 50px;  
}

button:hover:before { top: 0px; }

button:after {
    content: "Click";
    top: 0px;
    font-size: 30px;  
}

button:hover:after { top: 70px; } 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button></button>

【讨论】:

  • 感谢您的帮助,伙计..我尝试了与您所做的相同的操作,这没有问题..所有人都希望在单击时为同一个按钮添加一种效果..示例:当悬停符号时当我单击按钮时,类似地向下滚动,相同的符号必须执行一些其他效果,例如振动或旋转
  • @beep 我的回答没用,你没有标记吗?
  • 几乎没问题兄弟...我只是做了你已经做过的...我想要一个效果相同的按钮...1)当悬停带有文本的“铲子”符号应该从右移动到离开,然后回到它的位置。 2)如果点击它应该显示一些淡入淡出效果
  • 非常感谢兄弟..你节省了我的时间...现在我需要第二个要求
  • 好吧,我确实复制并粘贴了您的代码.. 不幸的是它在我的项目中不起作用
猜你喜欢
  • 2012-12-11
  • 1970-01-01
  • 2016-08-26
  • 1970-01-01
  • 1970-01-01
  • 2017-11-14
  • 2019-08-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多