style、 currentStyle、 runtimeStyle介绍
来源:互联网 发布:mba与emba的区别 知乎 编辑:程序博客网 时间:2024/05/16 10:54
style、 currentStyle、 runtimeStyle介绍
引自:http://hi.baidu.com/haoyan665/blog/item/6d5a995ce0c99747faf2c003.html
1、用到的基本概念:
内嵌样式(inline Style) :是写在Tag里面的,内嵌样式只对所有的Tag有效。
eg:<P style="font-size:20pt; color:red">这个Style定义<p></p>里面的文字是20pt字体,字体颜色是红色。</p>
内部样式(internal Style Sheet):是写在HTML的<head></head>里面的,内部样式只对所在的网页有效。
<HTML>
<HEAD>
<STYLE type="text/css">
H1.mylayout {border-width:1; border:solid; text-align:center; color:red}
</STYLE>
</HEAD>
<BODY>
<H1 class="mylayout"> 这个标题使用了Style。</H1>
<H1>这个标题没有使用Style。</H1>
</BODY>
</HTML>
外部样式表(External Style Sheet):如果很多网页需要用到同样的样式(Styles),将样式(Styles)写在一个以.css为后缀的CSS文件里,然后在每个需要用到这些样式(Styles)的网页里引用这个CSS文件。
<HEAD>
<link href="../asdocs/css_tutorials/home.css" rel="stylesheet" type="text/css">
</HEAD>
CSS第一个字母,是Cascading,意为串联。它是指不同来源的样式(Styles)可以合在一起,形成一种样式。
样式(Styles)的优先级依次是内嵌(inline), 内部(internal), 外部(external), 浏览器缺省(browser default)。
假设内嵌(Inline)样式中有font-size:30pt, 而内部(Internal)样式中有font-size:12pt,那么内嵌(Inline)式样式就会覆 盖内部(Internal)样式。
2、currentStyle 代表了在全局样式表、内嵌样式和
this);" target="_blank">HTML 标签属性中指定的对象格式和样式。
Style为内嵌样式。
style 标准的样式!可能是由style属性指定的!
runtimeStyle 运行时的样式!如果与style的属性重叠,将覆盖style的属性!
currentStyle 指 style 和 runtimeStyle 的结合!
当指定了runtimeStyle,那么当前显示的样式以runtimeStyle为准,如果取消了runtimeStyle,那么当前显示样式就恢复到currentStyle的样式。
<script>
function yangshi(){
//alert(document.getElementsByName("a")[0].value);
//alert(document.getElementsByName("b")[0].currentStyle);
alert("The td object currentStyle.width is " + oTd.currentStyle.width +
"/nThe td object style.width is " + oTd.style.width +
"/nThe td object style.textAlign is " + oTd.style.textAlign +
"/nThe td object currentStyle.textAlign is " +oTd.currentStyle.textAlign +
"/nThe td object style.font is " + oTd.style.fontSize +
"/nThe td object currentStyle.font is " + oTd.currentStyle.fontSize);
}
function runStyle(){
p1.style.backgroundColor = "red";
p1.runtimeStyle.color = "blue";
p1.runtimeStyle.backgroundColor = "green";
alert("000style=="+p1.style.backgroundColor);
alert("aaastyle=="+p1.style.color); //没有数据
alert("111runtime=="+p1.runtimeStyle.backgroundColor); //没有数据
alert("222runtime=="+p1.runtimeStyle.color);
alert("333currentStyle=="+p1.currentStyle.backgroundColor); //显示green,说明runtime优先级高
alert("444currentStyle=="+p1.currentStyle.color);
}
</script>
</head>
<body>
<input type="button" name="qq" value="Style" onclick="yangshi()">
<table border="1">
<tr>
<td width="1100" style="font-size:100px;text-align:right" id="oTd">text</td>
</tr>
</table>
<p id="p1">pppp</p><input type="button" name="ww" value="runtime" onclick="runStyle()" >
</body>
- style、 currentStyle、 runtimeStyle介绍
- style、 currentStyle、 runtimeStyle介绍
- style、 currentStyle、 runtimeStyle介绍
- style、currentStyle、runtimeStyle详解
- currentStyle,runtimeStyle,getComputedStyle style
- style、 currentStyle、 runtimeStyle区别分析
- .style .currentStyle .runtimeStyle 三者的差别
- Style currentStyle computedStyle 和 runtimeStyle 的区别
- style、 currentStyle、 runtimeStyle区别分析-javascript技巧
- style,runtimeStyle与currentStyle的定义及用法
- style,currentStyle,runtimeStyle,getComputedStyle的区别及用法
- js中style、currentStyle、getComputed、runtimeStyle的区别
- style,currentStyle,runtimeStyle,getComputedStyle的区别及用法
- style、currentStyle、getComputedStyle区别介绍
- style、currentStyle、getComputedStyle区别介绍
- style、currentStyle、getComputedStyle区别介绍
- style、currentStyle、getComputedStyle区别介绍
- style、currentStyle、getComputedStyle区别介绍
- [C#] 面向对象
- OCP-1Z0-053-200题-113题-158
- HBase 0.94 master启动过程源码分析
- CSBG群聊记录02(群号92210001)
- Single Number II
- style、 currentStyle、 runtimeStyle介绍
- 没有人能够一味地淡定,没有人能够一味地忍受
- DotnetBar在VS2010工具箱中不显示问题
- [C#]数组
- 不要去怨恨上天的不公平
- POJ 1284 Primitive Roots 原根(欧拉函数)
- 余弦的文章中的查询资料
- [C#] 字符串
- SSH框架 dataSource c3p0连接池配置说明