jsインライン以外のスタイルスタイルスタイルスタイルスタイル、currentStyle、getComputedStyleを読み込む
1442 ワード
インサートスタイル(inline Style):Tagに書かれており、インサートスタイルはすべてのTagにのみ有効です.内部スタイル(internal Style Sheet):HTMLのに書かれており、内部スタイルは所在するページにのみ有効です.外部スタイルシート(External Style Sheet):多くのページで同じスタイル(Styles)を使用する必要がある場合は、スタイル(Styles)を1つに書く.cssは接尾辞のCSSファイルにあり、これらのスタイル(Styles)が必要なページごとにこのCSSファイルを参照します.
コードはあまり言わない:
コードはあまり言わない:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Document</title>
<style>
#test{width:200px;}
</style>
<script>
</script>
</head>
<body>
<div id="test">this is test content</div>
<script type="text/javascript">
var oTest = document.getElementById('test');
if(oTest.currentStyle){
alert('ie: ' + oTest.currentStyle['width']);
} else {
alert('ff: ' + window.getComputedStyle(oTest, null)['width']);
}
</script>
</body>
</html>