美文网首页
前端页面筛选框置顶显示

前端页面筛选框置顶显示

作者: wsmmint | 来源:发表于2018-03-16 11:50 被阅读0次

    /**

     *筛选框置顶显示

     * @param {string} idname -需要置顶的元素id

     */

    function searchFloat(idname){

        var top = $(idname).position().top;

        $(window).scroll(function(){

            if($(document).scrollTop()> top){

    //这里是判断页面宽度过小就不再置顶

                if($(window).width()> 900){

                    $(idname).css({

                        "position":"fixed",

                        "top":0,

                        "z-index":999

                    });

                }else {

                    $(idname).css({

                        "position":""

                    });

                }

            }else{

                $(idname).css({

                    "position":""

                });

            }

        })

    }

    $(searchFloat("#headtype"));

    相关文章

      网友评论

          本文标题:前端页面筛选框置顶显示

          本文链接:https://www.haomeiwen.com/subject/gpmlqftx.html