CSS和JavaScript标签style属性对照表
一般情况是把"-"去掉,后面字母用大写。CSS语法 (不区分大小写) JavaScript语法 (区分大小写)border border
border-bottom borderBottomborder-bottom-color borderBottomColorborder-bottom-style borderBottomStyleborder-bottom-width borderBottomWidthborder-color borderColorborder-left borderLeftborder-left-color borderLeftColorborder-left-style borderLeftStyleborder-left-width borderLeftWidthborder-right borderRightborder-right-color borderRightColorborder-right-style borderRightStyleborder-right-width borderRightWidthborder-style borderStyleborder-top borderTopborder-top-color borderTopColorborder-top-style borderTopStyleborder-top-width borderTopWidthborder-width borderWidthclear clearfloat float //styleFloat(IE)/cssFloat(FireFox)margin marginmargin-bottom marginBottommargin-left marginLeftmargin-right marginRightmargin-top marginToppadding paddingpadding-bottom paddingBottompadding-left paddingLeftpadding-right paddingRightpadding-top paddingTop颜色和背景标签和属性对照
background backgroundbackground-attachment backgroundAttachmentbackground-color backgroundColorbackground-image backgroundImagebackground-position backgroundPositionbackground-repeat backgroundRepeatcolor color样式标签和属性对照
display displaylist-style-type listStyleTypelist-style-image listStyleImagelist-style-position listStylePositionlist-style listStylewhite-space whiteSpace文字样式标签和属性对照
font fontfont-family fontFamilyfont-size fontSizefont-style fontStylefont-variant fontVariantfont-weight fontWeight文本标签和属性对照
letter-spacing letterSpacingline-break lineBreakline-height lineHeighttext-align textAligntext-decoration textDecorationtext-indent textIndenttext-justify textJustifytext-transform textTransformvertical-align verticalAlign补充:
style 获取的是内联样式,即style属性中的值,可以用其改变元素显示样式currentStyle 只有 IE 和 Opera 支持,获取 HTMLElement 的计算后的样式,其他浏览器中不支持getComputedStyle 在标准浏览器中使用,IE9也支持getComputedStyle,但是支持不完全,比如border var element = document.getElementById("id");var currentStyle = element.currentStyle? element.currentStyle : window.getComputedStyle(element, null);var float = currentStyle.getPropertyValue("float")//float 旧版浏览器保持兼容的简单方式