javascript - Slidetoggle JS 元素内的文本中断

标签 javascript jquery css

我的网站有问题http://riskby.com/features/

如果向下滚动一点,然后单击 MyRiskby 菜单元素,文本将如下所示:

Text breaks after scroll in slidetoggle-element

这是我的 JS:

;(function ($) {
    $("#text-6").css({
        "display": "none"
    });
    $('#menu-item-990 a').click(function (event) {
        $('#text-6').slideToggle("fast");
    });
    $('#text-6').click(function (e) {
        e.stopPropagation();
    });
    $(document).click(function () {
        $('#text-6').slideUp();
    });
    $(window).scroll(function () {

        var a = 1;
        var pos = $(window).scrollTop();
        if (pos > a) {
            $("#text-6").css({
                position: 'fixed',
                top: '45px'
            });
        } else {
            $("#text-6").css({
                position: 'fixed',
                top: '89px'
            });
        }
    });
})(jQuery);

我可以以某种方式阻止这种情况发生吗?

到目前为止的状态:仍然没有找到解决方案。当我先向下滚动一点,然后单击 MyRiskby 时,就会发生文本中断...我的 JS 可能有问题吗?每个答案都非常感谢!谢谢!

fiddle : http://jsfiddle.net/mediabird/m186z4t7/1/

最佳答案

好吧,我找到了解决方案:

位置固定更改为绝对。所以相对简单;)。现在可以在我的计算机上运行。

希望它能在未来帮助别人。

关于javascript - Slidetoggle JS 元素内的文本中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30640689/

相关文章:

javascript - react : method return wrong value on componentDidMount

javascript - 如何在 lightGallery 中动态更改图像 url

javascript - 无法将从 api 提供的数据中检索到的背景图像添加到 div node.js

javascript - 我的导航栏上的显示/隐藏按钮 Bootstrap 不起作用

html - 如何裁剪/裁剪图像以适合浏览器窗口的高度?

javascript - 覆盖 css 不起作用

javascript - 在 Javascript 输出中添加逗号分隔符

jquery - 无法在 Bootstrap 中的弹出窗口内触发任何 javascript 事件

javascript - Bootstrap - 如何在两列中拆分和对齐下拉列表?

html - 在 CSS 中创建叠加层