您的位置:首页 > Web前端 > JavaScript

JavaScript Style Attributes

2015-06-05 22:26 666 查看

Listed below are the tables of CSS properties for various HTML element style attributes. I have added a column indicating the javaScript name that the browser recognizes for these properties. I have only listed those that I know work, but the trend seems
to be to use the same name when one name is the style descriptor. When there are two names, use the first name in lower case and the first character of the second name in upper case. Examples:

color = color
background-color = backgroundColor
font-style = fontStyle
font-weight = fontWeight

Box Properties

NameJavaScript NameDescriptionPossible ValuesElement TypesExampleinherited
borderSets border width, style and color.See border width, style, and colorAll{border: medium solid green}No
border-bottomSet the bottom border width style, and color.See border width, style, and colorAll{border-bottom: medium solid green}No
border-bottom-widthSet the bottom border widththin, medium, thick, or length valueAll{border-bottom-width: thin}No
border-colorSet the border colorA color value, color, #RRGGBBAll{border: #0000ff}No
border-leftSet the left border width style, and color.See border width, style, and colorAll{border-left: medium solid green}No
border-left-widthSet the left border widththin, medium, thick, or length valueAll{border-left-width: thin}No
border-rightSet the right border width style, and color.See border width, style, and colorAll{border-right: medium solid green}No
border-right-widthSet the right border widththin, medium, thick, or length valueAll{border-right-width: thin}No
border-styleSets border stylenone, dotted, dashed, solid, double, groove, ridge, inset, outsetAll{border: dashed}No
border-topSet the top border width style, and color.See border width, style, and colorAll{border-top: medium solid green}No
border-top-widthSet the top border widththin, medium, thick, or length valueAll{border-top-width: thin}No
border-widthSets Border width.thin, medium, thick, or length valueAll{border-width: 8}No
clearDetermines where floating elements are allowed.none, left, right, bothAll{clear: left}No
floatSpecifies how text is wrapped and where it is aligned.none, left, rightAll{float: left}No
heightHeight of elementauto or a height valueBlock elements and IMG, INPUT, TEXTAREA, SELECT, and OBJECT{height: 200}No
marginSet element margin width. A single value sets all margins, two values set top and bottom, four values set top, right, bottom, and left margins.auto, length value, or percent valueAll{margin: 4em 2em 4em 2em}No
margin-bottommarginBottomSet element bottom marginlength value, or percent valueAll{margin-bottom: 4em}No
margin-leftmarginLeftSet element left marginlength value, or percent valueAll{margin-left: 4em}No
margin-rightmarginRightSet element right marginlength value, or percent valueAll{margin-right: 4em}No
margin-topmarginTopSet element top marginlength value, or percent valueAll{margin-top: 4em}No
paddingSpace between border and content. A single value sets all sides, two values set top/bottom and left/right, three values set top, right/left, and bottom, and four values set top, right, bottom, and left.length value, or percent valueAll{padding: 4em}No
padding-bottomSpace between bottom border and content.length value, or percent valueAll{padding-bottom: 4em}No
padding-leftSpace between left border and content.length value, or percent valueAll{padding-left: 4em}No
padding-rightSpace between right border and content.length value, or percent valueAll{padding-right: 4em}No
padding-topSpace between top border and content.length value, or percent valueAll{padding-top: 4em}No
widthWidth of elementauto or a height value in length or percentageBlock elements and IMG, INPUT, TEXTAREA, SELECT, and OBJECT{width: 40em}No

Background and Color Properties

NameJavaScript NameDescriptionPossible ValuesElement TypesExampleinherited
backgroundSet background color, repeat, image, attachment, or position.See background-color, background-image, background-attachment, background-repeat, background-positionAll{background: #8080ff}No
background-attachmentDetermines if the background image is fixed or scroll.scroll, fixedAll{background-attachment: scroll}No
background-colorbackgroundColorSets the background color.Named or value colorAll{background-color: #8080ff}No
background-imageSets the background image.urlAll{background-image: url('../../../../gifs/flowers.gif')}No
background-positionSets the background image initial position.top, center, bottom, left, center, right, or percent valuesBlock and IMG, INPUT, TEXTAREA, SELECT, and OBJECT{background-position: left top}No
background-repeatSets how the background image is repeated.repeat, repeat-x, repeat-y, no-repeatAll{background-repeat: no-repeat}No
colorcolorSets element color.Named or value colorAll{color: green}Yes

Classification Properties

NameJavaScript NameDescriptionPossible ValuesElement TypesExampleinherited
displaySets the type of element.block, inline, list-item, noneAll{display: list-item}No
list-stylelistStyleSets list style type and/or position.See list-style-type and list-style-positionList-item{list-style: circle}Yes
list-style-imageSets image to be used as the list item marker.urlList-item{list-style-image: url(this.gif)}Yes
list-style-typeSets list style type.circle, disc, decimal, lower-alpha, lower-roman, none, square, upper-alpha, upper-romanList-item{list-style-type: square}Yes
list-style-positionSets where the marker is place relative to the text and its wrapping position.inside, outsideList-item{list-style: circle}Yes
whitespaceSets treatment of spaces inside the element.normal, pre, nowrapBlock{whitespace: pre}Yes

Font Properties

NameJavaScript NameDescriptionPossible ValuesElement TypesExampleinherited
fontUsed to define font propertiesSee font-family, font-size, font-style, font-variant, and font-weight.All{font: 20pt}Yes
font-familyfontFamilyUsed to define font family to usefamily nameAll{font-family: ariel roman}Yes
font-sizeUsed to define font size to usexx-small, x-small, small, medium, large, x-large, xx-large, larger, smaller, length value, or percent valueAll{font-size: 18pt}Yes
font-stylefontStyleUsed to define font style to usenormal, italic, obliqueAll{font-style: italic}Yes
font-variantfontVariantUsed to determine whether to use normal or small capsnormal, small-capsAll{font-variant: small-caps}Yes
font-weightfontWeightSets font weight.normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900All{font-weight: 600}Yes

Text Properties

NameJavaScript NameDescriptionPossible ValuesElement TypesExampleinherited
letter-spacingSets the space between characters.normal or length valueAll{letter-spacing: 0.2em}Yes
line-heightlineHeightSets the height of lines.normal, a number, a percent of the element font size,All{line-height: 2}Yes
text-aligntextAlignSets the alignment of text.left, right, center, justifyBlock{text-align: center}Yes
text-decorationtextDecorationSets the special decoration attributes of text.none, overline, underline, line-through, blinkAll{text-decoration: blink}No
text-indenttextIndentSets the element's first line amount of indentation.length or percentage valueBlock{text-indent: 5%}Yes
text-transformtextTransformTransforms text to one of the set values.none, capitalize, uppercase, lowercaseAll{text-transform: uppercase}Yes
vertical-alignverticalAlignSets vertical position.baseline, sub. super, top, middle, bottom, text-top, text-bottom, or percent valueInline{vertical-align: sub}No
word-spacingSets extra space between words.normal or length valueAll{word-spacing: 0.2em}Yes
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: