style

style style *
*前のトピック: STYLE
*次のトピック: styleSheet

style

解説

指定されたエレメントに対する全ての利用可能なインラインスタイルの現在の設定を示す。

注意事項

インラインスタイルはCSSのスタイルの適用方法で、STYLE=属性を使って個々のHTMLエレメントにスタイルを直接適用することができる。 styleオブジェクトを使って、これらの適用したものが何であるか、また新たに何か適用するか、適用したものを変更するかなどを行うことができる。

エレメントオブジェクトstyleキーワードを付けることによってstyleオブジェクトを読み出すことができる。styleオブジェクトにstyleプロパティを対応させるにより、現在適用されているスタイルを知ることができる。

styleオブジェクトを使って、スタイルシートのスタイルの引数にアクセスすることはできない。スタイルシートのスタイル情報を取得するには、styleSheetsコレクションを使用してドキュメント内で定義された個々のスタイルシートにアクセスしなければならない。

次の例は、ドキュメント ボディのテキスト タイプフェースを"Verdana"に設定している。

document.body.style.fontFamily = "Verdana"

次の例は、指定された画像をドキュメントのトップへ配置している。

var i = document.all.tags("IMG");
if (i.length>0) {
if (i[0].style.position == "absolute")
i[0].style.top = 0;
}

プロパティ

background, backgroundAttachment, backgroundColor, backgroundImage, backgroundPosition, backgroundPositionX, backgroundPositionY, backgroundRepeat, border, borderBottom, borderBottomColor, borderBottomStyle, borderBottomWidth, borderColor, borderLeft, borderLeftColor, borderLeftStyle, borderLeftWidth, borderRight, borderRightColor, borderRightStyle, borderRightWidth, borderStyle, borderTop, borderTopColor, borderTopStyle, borderTopWidth, borderWidth, clear, clip, color, cssText, cursor, display, filter, font, fontFamily, fontSize, fontStyle, fontVariant, fontWeight, height, left, letterSpacing, lineHeight, listStyle, listStyleImage, listStylePosition, listStyleType, margin, marginBottom, marginLeft, marginRight, marginTop, overflow, paddingBottom, paddingLeft, paddingRight, paddingTop, pageBreakAfter, pageBreakBefore, pixelHeight, pixelLeft, pixelTop, pixelWidth, posHeight, position, posLeft, posTop, posWidth, styleFloat, textAlign, textDecoration, textDecorationBlink, textDecorationLineThrough, textDecorationNone, textDecorationOverline, textDecorationUnderline, textIndent, textTransform, top, verticalAlign, visibility, width, zIndex

メソッド

getAttribute, removeAttribute, setAttribute

適用

エレメントオブジェクト

Up トップに戻る
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.