用jQuery更改css而没有出现任何过渡

黑色的

我有两个按钮,希望它们彼此相邻。我必须使用jquery来实现这一点,因为即使我使用“ display:inline-block”,只要单击“ Forward”按钮,就会出现“ Previous”按钮,而“ Forward”按钮移到底部。

它工作正常,但是有一个问题。jQuery更改了CSS之后,就可以看到按钮如何“过渡”到其新位置,正如您在我的jsfiddle代码中所看到的那样

问题:是否有办法更改此行为,并使更改可见而没有任何过渡或延迟?

<div id="mydiv_buttons">
    <div style="padding:20px;">
        <div class="col-md-9">
            <table style="margin-left: 500px">
                <tr>
                    <td><a class="btn"      id="btn_arrow-prev" >       <p class="button_text"> Previous    <i class="fa fa-angle-double-left"></i></p></a></td>
                    <td><a class="btn"      id="btn_arrow-next" >       <p class="button_text"> Forward     <i class="fa fa-angle-double-right"></i></p></a></td>
                </tr>
            </table>
        </div>
    </div>
</div>

的CSS

.btn {
    -moz-user-select: none;
    border: 1px solid rgba(0, 0, 0, 0);
    border-radius: 4px;
    cursor: pointer;
    display: inline-block;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.42857;
    margin-bottom: 0;
    padding: 6px 12px;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}
.btn {
    background-image: none !important;
    border: 5px solid #FFFFFF;
    border-radius: 0;
    box-shadow: none !important;
    color: #FFFFFF !important;
    cursor: pointer;
    display: inline-block;
    margin: 0;
    position: relative;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25) !important;
    transition: all 0.15s ease 0s;
    vertical-align: middle;
}
.btn, .btn-default, .btn:focus, .btn-default:focus {
    background-color: #ABBAC3 !important;
    border-color: #ABBAC3;
}

.button_text
{
    margin-top: 7px;
    font-size: 15px;
}

#mydiv_buttons
{
    margin-top: 440px;
    width:100%;
    height:20%;

    border-top: 1px solid #D8D8D8;
}

jQuery的:

var main = function()
{
    var counter = 1;
    var m_left = "148px";

    if (counter === 1)
    {
        $("#btn_arrow-next")            .css("display", "inline-block");
        $("#btn_arrow-next")            .css("margin-left", m_left);        

        $("#btn_arrow-prev")            .css("display", "none");        
        $("#btn_fertig_stellen")        .css("display", "none");        
    } 

    $('#btn_arrow-next').click
    (
        function()
        {
            counter = counter + 1;

            if (counter === 1)
            {
                $("#btn_arrow-next")            .css("display", "inline-block");    
                $("#btn_arrow-next")            .css("margin-left", m_left);    

                $("#btn_arrow-prev")            .css("display", "none");
                $("#btn_fertig_stellen")        .css("display", "none");
            } 
            else if (counter === 2)
            {
                $("#btn_arrow-next")            .css("display", "inline-block");
                $("#btn_arrow-next")            .css("margin-left","0px");
                $("#btn_arrow-prev")            .css("display", "inline-block");
            }

        }
    );

    $('#btn_arrow-prev').click
    (
        function()
        {
            counter = counter - 1;

            if (counter === 1)
            {
                $("#btn_arrow-next")            .css("display", "inline-block");
                $("#btn_arrow-next")            .css("margin-left", m_left);

                $("#btn_arrow-prev")            .css("display", "none");
                $("#btn_fertig_stellen")        .css("display", "none");
            } 
            else if (counter === 2)
            {
                $("#btn_arrow-next")            .css("display", "inline-block");
                $("#btn_arrow-next")            .css("margin-left","0px");
                $("#btn_arrow-prev")            .css("display", "inline-block");
            }

        }   
    );

}

$(document).ready(main);

https://jsfiddle.net/69802n3f/

鲁迪·维瑟(Rudie Visser)

transition在CSS中设置了A transition: all 0.15s ease 0s;btn类中删除

小提琴

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

带有+分隔参数的System.out.println无法打印完整的输出,也不会出现任何错误

Vue JS 2.0没有呈现任何内容?

更改innerHTML时是否有任何过渡效果的方法?

CSS过渡延迟进入但没有退出

绑定延迟属性WPF-我没有发现任何区别

使用RecyclerView并从Web服务获取信息,但不显示答案,并且没有出现任何错误,为什么?

为什么显示更改后没有立即启动CSS过渡

为什么屏幕上没有出现任何项目符号?-pygame

我无法更改CSS中的任何内容,没有任何效果

为什么我的PHP网站没有呈现任何CSS或链接?

为什么我的wss://(基于SSL / TLS的WebSockets)连接立即断开连接而没有出现任何错误?

用jQuery更改“样式”的CSS过渡问题

突然出现“双NAT”警告,而对网络没有任何更改?

jQuery的选择标签更改启用没有用

我用块匹配算法找到的绘图矢量没有发现任何变化

jQuery的警报没有出现

Java Jframe 没有编译错误,但我的 JPanel 中没有出现任何内容

没有出现任何异常,但数据没有存储到数据库中

knitr:为什么编译我的 .Rnw 文件时“环境”面板中没有出现任何内容

如果 preg_match 没有发现任何回声

Python 程序没有给出错误或警告,但也没有出现任何窗口

尝试使用返回按钮组件但没有呈现任何内容的函数

功能有效,但单元格中没有出现任何内容

Haskell , 用 foldr 实现任何功能

为什么@Autowired 会引发 UnsatisfiedDependencyException,即使该类没有实现任何接口?

我的视图没有在模板中呈现任何结果 - django

当触发器没有发现任何错误时继续存储过程

CSS 过渡显示:没有反转

CSS过渡没有响应