• Home  >  Article  >  Web Front-end  >  关于jquery css的使用介绍_jquery

    关于jquery css的使用介绍_jquery

    WBOY
    WBOYOriginal
    2016-05-16 17:36:22933browse

    jQuery 操作 CSS

    • addClass() - 向被选元素添加一个或多个类
    • removeClass() - 从被选元素删除一个或多个类
    • toggleClass() - 对被选元素进行添加/删除类的切换操作
    • css() - 设置或返回被选元素的一个或多个样式属性。

    jQuery css() 方法

    〈1〉返回 CSS 属性

    css("propertyname");

    〈2〉设置 CSS 属性

    css("propertyname","value");

    〈2.1〉设置多个 CSS 属性

    css({"propertyname":"value","propertyname":"value",...});

    jQuery 尺寸 方法

    jQuery 提供多个处理尺寸的重要方法:

    • width() 设置或返回元素的宽度(不包括内边距、边框或外边距)。
    • height() 设置或返回元素的高度(不包括内边距、边框或外边距)。
      设置:$("#div1").width(500).height(500); more : $(window/document).width/height;
    • innerWidth() 返回元素的宽度(包括内边距)。
    • innerHeight() 返回元素的高度(包括内边距)。
    • outerWidth() 返回元素的宽度(包括内边距、边框和外边距)。
    • outerHeight() 返回元素的高度(包括内边距、边框和外边距)。
    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn