<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#div1{ color:blue; background:blue; width:100px;}
</style>
<script src="jquery-2.0.3.js"></script>
<script>
一些变量
function vendorPropName(){}
function isHidden(){}
function getStyles(){}
function showHide(){}
jQuery.fn.extend({
css
show
hide
toggle
});
jQuery.extend({
cssHooks
cssNumber
cssProps
style
css
});
curCSS = function(){};
function setPositiveNumber(){}
function augmentWidthOrHeight(){}
function getWidthOrHeight(){}
function css_defaultDisplay(){}
function actualDisplay(){}
一些cssHooks $(function(){
console.log($('#div1').get(0).style.color);//原生方法,只能得到行内样式,不能得到外部css文件中的样式,
console.log( window.getComputedStyle( $('#div1').get(0), null).color);//得到外部文件的样式,获取最终样式,行内样式和外部样式冲突时返回行内样式, console.log(window.getComputedStyle( $('#div1').get(0) , null ).background);//不能获取复合样式background,要写background-color,
console.log($('#div1').get(0).style.background);//可以得到复合样式 console.log( $('#div1').css('color') );
$('#div1').css('color','yellow');
console.log( $('#div1').css('color') ); //$('#div1').css('color','yellow')--->jQuery.style()--->style
//$('#div1').css('color')--->jQuery.css()--->curCSS = function(){}--->getComputedStyle console.log($('#div1').css(['color','backgroundColor','width']));
$('#div1').css({width:200,height:200});
$('#div1').css('width',function(){
return 500;
}); ---------------------------------------------------------------- $('#div1').width()/height()/innerWidth()/innerHeight()/outerWidth()/outerHeight()
$('#div1').css('background-color');
$('#div1').css('float'); getComputedStyle(oDiv,null).backgroundColor getComputedStyle(oDiv,null).backgroundColor
style.cssFloat
//class -> className //$('#div1').css('tranfroms'); $('#div1').css('width'); '123px'
$('#div1').width(); 123 }); </script>
</head> <body>
<div id="div1" style="MozTranfroms">aaaaaaaaaaaa</div>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#div1{ width:100px;}
</style>
<script src="jquery-2.0.3.js"></script>
<script>
$(function(){
alert(window.getComputedStyle( $('#div1').get(0) , null )['filter']); alert(window.getComputedStyle( $('#div1').get(0) , null ).getPropertyValue('filter')); var $span = $('<span>');//动态创建一个元素
$span.css('width','100px');
$span.css('width'); console.log($('#div1').css('margin-left')); $('#div1').css('width','+=100'); });
</script>
</head> <body>
<div id="div1">aaaaaaaaaaaa</div>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#div1{ display:none;}
</style>
<script src="jquery-2.0.3.js"></script>
<script> $(function(){//检测dom节点加载完,有可能iframe里面的页面还没有加载完
$('#div1').hide();// display -> none
$('#div1').show();// display -> block
$('#div1').toggle();
$('#div1').toggle(false);// 只会 hide()
$('#div1').toggle(true);// 只会 show() $('#div1').hide();// -> jQuery.css() -> getComputedStyle().display table -> data
$('#div1').show();// -> elem.nodeName -> 'div' -> createElement('div'); -> jQuery.css() }); $(window).load(function(){//iframe里面的页面加载完了
//get(0)转原生
var div = $('iframe').get(0).contentWindow.document.getElementById('div1');
console.log(window.getComputedStyle(div,null).display); $(div).show();
$('iframe').show(); }); </script>
</head> <body>
<!--<div id="div1">aaaaaaaaaaaa</div>-->
<iframe src="53jq.html" style="display:none"></iframe>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#div1{ display:none}
</style>
</head> <body>
<div id="div1">aaaaaaaaaaa</div>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#div1{ width:100px; height:100px; background:red; padding:10px; border:1px blue solid; margin:5px;}
</style>
<script src="jquery-2.0.3.js"></script>
<script>
$(function(){ console.log( $('#div1').css('opacity') );//1,不写是1 $('#div1').width()/height()/innerWidth()/innerHeight()/outerWidth()/outerHeight()
-------------------------------------------------------------------
//$('#div1').width() -> $('#div1').css('width')
console.log($('#div1').width()); //100 width
console.log($('#div1').innerWidth()); //120 width + padding
console.log($('#div1').outerWidth()); //122 width + padding + border
console.log($('#div1').outerWidth(true)); //132 width + padding + border + margin
$('#div1').width(200); //width = 200
$('#div1').innerWidth(200); //width = 200 - padding
$('#div1').outerWidth(200); //width = 200 - padding - border
$('#div1').outerWidth(200,true); //width = 200 - padding - border - margin console.log($('#div1').get(0).offsetWidth); //隐藏获取是0
console.log( $('#div1').width() ); //jquery隐藏也可以获取100
//$('#div1').width() , innerWidth() , outerWidth()
//$.css() 获取
//$.style() 设置
//content/padding/border/margin
//cssHooks.get()
//cssHooks.set() function setPositiveNumber(){}
function augmentWidthOrHeight(){}
function getWidthOrHeight(){}
$(window).height()//可视区的高
$(document).height()//整个页面的高度 $('div:visible') $('div').animate({ margin : '10px 20px 30px 40px' }); marginLeft -> 40
marginRight -> 20
marginTop -> 10
marginBottom -> 30 });
</script>
</head> <body>
<div id="div1" style="display:table-column">aaaaaaaaaaa</div>
</body>
</html>

jquery18 css() : 样式的操作的更多相关文章

  1. 利用JS脚本通过getAttribute()和setAttribute()等对CSS样式进行操作

    HTML中引入CSS样式的方式有三种: 1.最常用的,引入样式表,在样式表中编写样式,引入方式如下:<link href="css/style.css" rel=" ...

  2. JavaScript对css样式表操作

    CSS样式表3种方式: 内嵌:写在html标签中的样式 :如:<p style="width:100px"> 内嵌</p> 内联:写在html 中<h ...

  3. CSS样式之操作属性二

    ********css样式之属性操作******** 一.文本属性 1.text-align:cnter 文本居中 2.line heigth 垂直居中 :行高,和高度对应 3.vertical-al ...

  4. CSS样式之操作属性一

    ********css之操作属性******** 一.文本 1.文本颜色:color 颜色属性被用来设置文字的颜色 颜色是通过CSS最经常的指定: 十六进制值 - 如: #FF0000 一个RGB值 ...

  5. jquery源码09 (6058 , 6620) css() : 样式的操作

    var curCSS, iframe, // swappable if display is none or starts with table except "table", & ...

  6. JQuery中操作Css样式的方法

    JQuery中操作Css样式的方法//1.获取和设置样式 $("#tow").attr("class")获取ID为tow的class属性 $("#tw ...

  7. jquery轻松操作CSS样式

    $(this).click(function(){  if($(this).hasClass(“zxx_fri_on”)){    $(this).removeClass(“zxx_fri_on”); ...

  8. try.jquery-5-styling里的各种css样式操作

    你好,这里是我的http://try.jquery.com/学习笔记: 这次来学习操作各种css. 主要对这段html元素进行操作. <div id="all-tours"& ...

  9. jQuery操作css样式

    jQuery操作css样式 css操作的分类: css操作 位置操作 尺寸操作 css操作之css css代码: html代码: jQuery代码: 效果如下: css操作之位置操作 css代码: h ...

随机推荐

  1. Wow C++11

    什么是C++11? 一句话C++11是最新的C++标准,在2011年发布,所以叫C++11.在新的标准出现前,我们一直在用的是C++98,可想而知这份标准是1998年发布的,之后再2003年最过小的修 ...

  2. java操作文件创建、删除

    java操作文件创建.删除: package test; import java.io.File; import java.io.IOException; import org.slf4j.Logge ...

  3. C语言基础-第六章

    数组和字符串 1.一维数组 数组当中最简单的数据 声明: 类型说明符 数组名[常量表达式] int a[3];说明a的长度为3,那么给a赋值的语句是:a={1,2,3}; 2.多维数组 2.1 二维数 ...

  4. Spring深入浅出(四)AOP面向切面

    面向切面编程--AOP AOP(Aspect Oriented Programming),程序员称之为面向切面编程,是Spring框架除了IOC之外的另一个核心概念. AOP是对OOP(面向对象编程) ...

  5. 最标准的 Java MySQL 连接

    package com.runoob.test; import java.sql.*; public class MySQLDemo { // JDBC 驱动名及数据库 URL static fina ...

  6. PostgreSQL环境中查看SQL执行计划示例

    explain   analyze ,format,buffers, format :TEXT, XML, JSON, or YAML. EXPLAIN (ANALYZE,buffers,format ...

  7. <Sicily>Pair

    一.题目描述 The N cities of Estiah are connected by N-1 roads. The roads are built in a way that it's alw ...

  8. Android chromium 1

    For Developers‎ > ‎Design Documents‎ > ‎ Java Resources on Android Overview Chrome for Android ...

  9. 比起 Windows,怎样解读 Linux 的文件系统与目录结构?

    Linux 和 Windows 的文件系统有些不同,在学习使用 Linux 之前,若能够了解这些不同,会有助于后续学习. 本文先对 Windows 和 Linux 上面文件系统原理.组织概念进行区分, ...

  10. 一篇文章助你理解Python2中字符串编码问题

    前几天给大家介绍了unicode编码和utf-8编码的理论知识,没来得及上车的小伙伴们可以戳这篇文章:浅谈unicode编码和utf-8编码的关系.下面在Python2环境中进行代码演示,分别Wind ...