【JQuery】css操作

本文介绍了使用JQuery进行CSS样式设置与获取的方法,包括高度、宽度调整及元素位置操作等核心功能。同时覆盖了scrollLeft、scrollTop等滚动条位置控制,以及offset和position等元素定位技巧。

一、前言

        接着上一章的内容,继续JQuery的学习

 

二、内容

css  设置或返回匹配元素的样式属性
     $(selector).css(css-property-name)
     $(selector).css(css-property-name,value)
     $(selector).css({property:value, property:value, ...})
     $(selector).css(css-property-name,function(index,currentvalue))


height  设置或返回匹配元素的高度
     $(selector).height()
     $(selector).height(num)
     $(selector).height(function(index,currentheight))


width  设置或返回匹配元素的宽度
     $(selector).width()
     $(selector).width(num)
     $(selector).width(function(index,currentwidth))


position  返回匹配元素相对于父元素的位置(偏移)
          返回的对象包含两个整型属性:top 和 left
     $(selector).position()


scrollLeft  设置或返回匹配元素相对滚动条左侧的偏移
     $(selector).scrollLect()
     $(selector).scrollLeft(new-position)


scrollTop   设置或返回匹配元素的滚动条的垂直元素
     $(selector).scrollTop()
     $(selector).scrollTop(offset)


offset  返回或设置匹配元素相对于文档的偏移
     $(selector).offset()
     $(selector).offset(value)
     $(selector).offset(function(index,currentoffset))


offsetParent  返回最近的祖先定位元素
     $(selector).offsetParent()

 

   

转载于:https://www.cnblogs.com/lovecsharp094/p/8448716.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值