E-gradiva > Računalništvo > Programiranje > Načrtovanje in razvoj spletnih aplikacij > Javascript > DOM (Document Object Model) > Razred Style

Prijava

Razred Style

Objekt Style vsebuje lastnosti določenega stavka za definicijo stila. Objekte razreda style lahko dosežemo preko posameznih elementov, za katere je ta stil definiran.

Primer dostopa do določenega stila:

 

Kako dostopamo slovnica:

       document.getElementById("id").style.lastnost= "vrednost"

      

Dejanska primera:

       document.body.style.background="#FFCC80 url(bgdesert.jpg) repeat-y";

       document.getElementById("p1").style.border="thick solid #0000FF";

 

Lastnosti objektov razreda Style

Definiranje ozadja background, backgroundAttachment, backgroundColor, backgroundImage, backgroundPosition, backgroundPosition X, backgroundPositionY, backgroundRepeat.

Definiranje pisave in izpisa besedila: color, font, fontFamily , fontSizefontSizeAdjust, fontStretch, fontStyle, fontVariant, fontWeight, letterSpacing, lineHeight, quotes, textAlign, textDecoration, textIndent, textShadow, textTransform, unicodeBidi, whiteSpace, wordSpacing, dir, lang, title.

Definiranje obrobe in odmikov: border, borderBottom, borderBottomColor, borderBottomStyle. borderBottomWidth, borderColor, borderLeft , borderLeftColor, borderLeftStyle, borderLeftWidth, borderRight , borderRightColor , borderRightStyle , borderRightWidth, borderStyle, borderTopStyle, borderTopWidth, borderWidth, margin, marginBottom marginLeft,,marginRight, marginTop, outline, outlineColor, outlineStyle, outlineWidth, padding , paddingBottom, paddingLeft, paddingRight, paddingTop.

Definiranje pozicije in velikosti elementov:clear, clip, content, counterIncrement, counterReset, cssFloat cursor, direction, display, height, markerOffset, marks, maxHeight, maxWidth, minHeight, minWidth, overflow, verticalAlign, visibility, width, bottom, left, position, right, top, zIndex.

Delo s seznami: listStyle, listStyleImage, listStylePosition, listStyleType.

Lastnosti tabel: borderCollapse, borderSpacing, captionSide, emptyCells, tableLayout.

Tiskanje:  orphans, page, pageBreakAfter, pageBreakBefore, pageBreakInside, size, widows.

Lastnosti drsnika( deluje samo v IE): scrollbar3dLightColor, scrollbarArrowColor, scrollbarBaseColor, scrollbarDarkShadowColor, scrollbarFaceColor, scrollbarHighlightColor, scrollbarShadowColor, scrollbarTrackColor.

 

Primer: spremeni ozadje dokumenta


<html>

       <head>

           <script type="text/javascript">

               function spremeniOzadje()

                  {

                    document.body.style.background="#FFCC80 url(bgdesert.jpg) repeat-y";

                   }

            </script>

       </head>

       <body>

               <input type="button" onclick="spremeniOzadje()" value="Spremeni ozadje" />

       </body>

</html>