jQuery慢慢啃之CSS(六)
1.css(name|pro|[,val|fn])//访问匹配元素的样式属性
$("p").css("color");//获取
$("p").css({ "color": "#ff0011", "background": "blue" });//属性组设置
$("p").css("color","red");//单个设置
$("div").click(function() {//函数形式设置
$(this).css({
width: function(index, value) {
return parseFloat(value) * 1.2;
},
height: function(index, value) {
return parseFloat(value) * 1.2;
}
});
});
2.jQuery.cssHooks//直接向 jQuery 中添加钩子,用于覆盖设置或获取特定 CSS 属性时的方法,目的是为了标准化 CSS 属性名或创建自定义属性。
3.offset([coordinates])//获取匹配元素在当前视口的相对偏移
<p>Hello</p><p>2nd Paragraph</p>
var p = $("p:last");
var offset = p.offset();
p.html( "left: " + offset.left + ", top: " + offset.top );<p>Hello</p><p>left: 0, top: 35</p>
$("p:last").offset({ top: 10, left: 30 });
//获取相对值
4.position()//获取匹配元素相对父元素的偏移。
var p = $("p:first");
var position = p.position();
$("p:last").html( "left: " + position.left + ", top: " + position.top );
5.scrollTop([val])//获取匹配元素相对滚动条顶部的偏移
var p = $("p:first");
$("p:last").text( "scrollTop:" + p.scrollTop() );$("div.demo").scrollTop(300);
//设置相对滚动条顶部的偏移,不一定是浏览器
6.scrollLeft([val])//获取匹配元素相对滚动条左侧的偏移
var p = $("p:first");
$("p:last").text( "scrollLeft:" + p.scrollLeft() );
$("div.demo").scrollLeft(300);
7.height([val|fn])//取得匹配元素当前计算的高度值
$("p").height();
//获取第一段的高
$("p").height(20);
8.width([val|fn])//取得第一个匹配元素当前计算的宽度值(px)。
9.innerHeight()//获取第一个匹配元素内部区域高度(包括补白、不包括边框)。
var p = $("p:first");
$("p:last").text( "innerHeight:" + p.innerHeight() );
10.innerWidth()//获取第一个匹配元素内部区域宽度(包括补白、不包括边框)。
var p = $("p:first");
$("p:last").text( "innerWidth:" + p.innerWidth() );
11.outerHeight([options])//获取第一个匹配元素外部高度(默认包括补白和边框)。
var p = $("p:first");
$("p:last").text( "outerHeight:" + p.outerHeight() + " , outerHeight(true):" + p.outerHeight(true) );
12.outerWidth([options])//获取第一个匹配元素外部宽度(默认包括补白和边框)。
var p = $("p:first");
$("p:last").text( "outerWidth:" + p.outerWidth() + " , outerWidth(true):" + p.outerWidth(true) );
jQuery慢慢啃之CSS(六)的更多相关文章
- jQuery慢慢啃之事件对象(十一)
1.event.currentTarget//在事件冒泡阶段中的当前DOM元素 $("p").click(function(event) { alert( event.curren ...
- jQuery慢慢啃之工具(十)
1.jQuery.support//一组用于展示不同浏览器各自特性和bug的属性集合 2.jQuery.browser//浏览器内核标识.依据 navigator.userAgent 判断. 可用值: ...
- jQuery慢慢啃之ajax(九)
1.jQuery.ajax(url,[settings])//通过 HTTP 请求加载远程数据 如果要处理$.ajax()得到的数据,则需要使用回调函数.beforeSend.error.dataFi ...
- jQuery慢慢啃之事件(七)
1.ready(fn)//当DOM载入就绪可以查询及操纵时绑定一个要执行的函数. $(document).ready(function(){ // 在这里写你的代码...}); 使用 $(docume ...
- jQuery慢慢啃筛选(四)
1.eq(index|-index) 获取第N个元素 其中负数:一个整数,指示元素的位置,从集合中的最后一个元素开始倒数.(1算起) $("p").eq(1)//获取匹配的第二个元 ...
- jQuery慢慢啃之核心(一)
1. $("div > p"); div 元素的所有p子元素. $(document.body).css( "background", "bla ...
- jQuery慢慢啃之回调(十三)
1.callbacks.add(callbacks)//回调列表中添加一个回调或回调的集合 // a sample logging function to be added to a callback ...
- jQuery慢慢啃之特效(八)
1.show([speed,[easing],[fn]])\\显示隐藏的匹配元素 //speed:三种预定速度之一的字符串("slow","normal", o ...
- jQuery慢慢啃之文档处理(五)
1.append(content|fn)//向每个匹配的元素内部追加内容. $("p").append("<b>Hello</b>"); ...
随机推荐
- Linux Eclipse代码提示功能设置(Java & C/C++)
最近在Linux下开发,由于长期使用Visual Studio 2010,对代码提示功能情有独钟,现在在Linux下,使用Eclipse做开发,当然免不了怀念Visual Studio强悍的代码提示, ...
- HDU-4952 Number Transformation
http://acm.hdu.edu.cn/showproblem.php?pid=4952 Number Transformation Time Limit: 2000/1000 MS (Java/ ...
- iOS中控件的Frame属性和Bounds属性的区别
在iOS中,每个控件都是继承于UIView的,都会有视图的属性存在,控制这个视图的位置就有Frame和Bounds两个属性 frame指的是:该view在父view坐标系统中的位置和大小.(参照点是父 ...
- Java 中UDP原理机制及实现方式介绍(建议阅读者阅读前了解下Java的基础知识,一方便理解)
1.基本概念介绍: 首先得简单介绍下UDP. UDP( User Datagram Protocol )协议是用户数据报,在网络中它与TCP协议一样用于处理数据包.在OSI模型中,在第四层——传输层, ...
- 《University Calculus》-chaper8-无穷序列和无穷级数-泰勒定理的证明
泰勒定理: 证明:
- XMPP and Asterisk integration
http://www.mundoopensource.com.br/en_page_xmpp_asterisk_pratical_example/ www.mundoopensource.com.br ...
- shiro能做什么,做j2ee时候要考虑什么
转载: http://jinnianshilongnian.iteye.com/blog/2018398, 感谢原作者 <跟我学Shiro>PDF完结版下载 博客分类: 跟 ...
- 自己生成非官方iPhone toolchain的头文件
如果你已经搭建好非官方iPhone toolchain开发包,如果缺少某些头文件,可以用以下方法自己生成. 首先下载class-dump: http://www.codethecode.com/pro ...
- C++ 标准时间线
Herb Sutter在他的博客上贴出了一个C++的timeline,如下所示:
- javascript数组基本方法
一.数组方法 1)concat 该方法用于连接两个或多个数组,返回连接成的新数组的副本,不会改变现有数组 [1,2,3].concat(5,6);//返回[1,2,3,5,6] 2)join 用于把数 ...