码迷,mamicode.com
首页 > Web开发 > 详细

jquery 学习(五) - CSS 操作

时间:2018-10-29 16:08:55      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:otto   func   function   add   jquer   onclick   lse   .sh   相对   

HTML + CSS 样式

/*CSS样式*/
<
style> body{ margin: 0; } div{ width: 100%; height: 2000px; background-color: aquamarine; margin: 0; } .a1{ position: fixed; right: 20px; bottom: 20px; width: 90px; height: 30px; background-color: darkgoldenrod; color: white; } .ds{ display: none; } </style>
/*HTML*/ <div></div> <div> <button class="a1 ds" onclick="f2()">返回顶部</button> </div>

 

CSS操作

//CSS 操作:

    //样式操作:
        $("").css({属性:值})

    //偏移量属性
        $("").offset.属性
        //相对于视图的偏移量

        $("").position.属性
        //相对于父标签的偏移量

    //尺寸大小
        $("").height(‘数值‘)
        $("").width(‘数值‘)

        $("").innerHeight(‘数值‘)
        $("").innerWidth(‘数值‘)

        $("").outerHeight(‘数值‘)
        $("").outerWidth(‘数值‘)

    //滚动条
    $("").scrollTop(数值)
    $("").scrollLeft(数值)


    //必须定义到windows事件里
    //windows onscroll 监听事件
    window.onscroll=function f() {
        var num = $(window).scrollTop();
        if (num >500){
            // $(‘.a1‘).removeClass(‘ds‘)
            $(‘.a1‘).show(1000)
        }
        else {
            // $(‘.a1‘).addClass(‘ds‘)
            $(‘.a1‘).hide(1000)
    }};

    function f2() {
        $(window).scrollTop(0)
    }

 

jquery 学习(五) - CSS 操作

标签:otto   func   function   add   jquer   onclick   lse   .sh   相对   

原文地址:https://www.cnblogs.com/Anec/p/9870751.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!