zoukankan      html  css  js  c++  java
  • javascript-jquery对象的css处理

    一、css基本属性处理

    1.css()方法:获取css属性值。$("选择器").css(name);//获取匹配选择器的元素指定css属性值。

    2.css()方法:设置css属性值。$("选择器").css(name,value);//设置匹配选择器的元素指定css属性的值。

    $("p").css("border","1px solid #f00");

    也可以一次设置多属性值

    $("p").css({"background-color":"green","color":"white"});

    二、css尺寸属性处理

    1.height()和width()方法:如果要获取或设置css属性height、width的值,可以使用更为简洁的height()和width()方法,单位是像素。

    $("div").width();//获取第一个div的width

    $("div").width(30);//设置多有的div的width为30px;

    2.innerHeight()和innerWidth()方法。用户获得或者设置元素的实际高度和宽度值。

      --是padding+width的值。

        -$("div").innerWidth();获得实际宽度,包括padding+width不包括border

    3.outerHeight()和outerWidth()方法。用户获得或者设置元素的实际高度和宽度。

      $("div").outerWidth(true);//获得实际宽度,包括padding+width+margin

    三、css位置属性设置。

    1.offset();获取或者设置当前元素相对窗口偏移量。

      --$("p").offset().top;//获取第一个距离窗口向上的偏移距离。

      --$("p").offset({"top":40,"left":15});

    2.position();方法:获取当前元素相对父元素的偏移量。

       --$("p").position().top;//获取第一个p距离父元素向上的偏移距离。

    3.scrollTop()和scrollLeft()方法:获取或者设置滚动条的位置。

      --$("div:eq(1)").scrollTop();//获得滚动条的距离位置

       --$("div:eq(1)").scrollTop(37);

  • 相关阅读:
    【交互稿】sample
    【公开数据】网站
    【交互】规范
    【Flask】https
    【Flask】run with ssl /https
    需求模版
    低功耗蓝牙BLE外围模式(peripheral)-使用BLE作为服务端
    AIDL示例
    Android使用BLE(低功耗蓝牙,Bluetooth Low Energy)
    Android网络访问库
  • 原文地址:https://www.cnblogs.com/yaxinwang/p/6420002.html
Copyright © 2011-2022 走看看