js控制CSS樣式屬性語法對(duì)照表
CSS與JS緊密配合,為我們的頁面增添了很多別致的效果。為了達(dá)到某種特殊的效果我們需要用Javascript動(dòng)態(tài)的去更改某一個(gè)標(biāo)簽的CSS屬性。
例如常用的關(guān)閉某個(gè)漂浮的廣告顯示:document.getElementById('ad').style.display='none';相當(dāng)于:.ad{ display:none}.
下面就是JS 控制CSS樣式表的語法對(duì)照:
盒子標(biāo)簽和屬性對(duì)照 | |
CSS語法(不區(qū)分大小寫) | JavaScript語法(區(qū)分大小寫) |
border | border |
border-bottom | borderBottom |
border-bottom-color | borderBottomColor |
border-bottom-style | borderBottomStyle |
border-bottom-width | borderBottomWidth |
border-color | borderColor |
border-left | borderLeft |
border-left-color | borderLeftColor |
border-left-style | borderLeftStyle |
border-left-width | borderLeftWidth |
border-right | borderRight |
border-right-color | borderRightColor |
border-right-style | borderRightStyle |
border-right-width | borderRightWidth |
border-style | borderStyle |
border-top | borderTop |
border-top-color | borderTopColor |
border-top-style | borderTopStyle |
border-top-width | borderTopWidth |
border-width | borderWidth |
clear | clear |
float | floatStyle |
margin | margin |
margin-bottom | marginBottom |
margin-left | marginLeft |
margin-right | marginRight |
margin-top | marginTop |
padding | padding |
padding-bottom | paddingBottom |
padding-left | paddingLeft |
padding-right | paddingRight |
padding-top | paddingTop |
顏色和背景標(biāo)簽和屬性對(duì)照 | |
CSS 語法(不區(qū)分大小寫) | JavaScript 語法(區(qū)分大小寫) |
background | background |
background-attachment | backgroundAttachment |
background-color | backgroundColor |
background-image | backgroundImage |
background-position | backgroundPosition |
background-repeat | backgroundRepeat |
color | color |
樣式標(biāo)簽和屬性對(duì)照 | |
CSS語法(不區(qū)分大小寫) | JavaScript 語法(區(qū)分大小寫) |
display | display |
list-style-type | listStyleType |
list-style-image | listStyleImage |
list-style-position | listStylePosition |
list-style | listStyle |
white-space | whiteSpace |
文字樣式標(biāo)簽和屬性對(duì)照 | |
CSS 語法(不區(qū)分大小寫) | JavaScript 語法(區(qū)分大小寫) |
font | font |
font-family | fontFamily |
font-size | fontSize |
font-style | fontStyle |
font-variant | fontVariant |
font-weight | fontWeight |
文本標(biāo)簽和屬性對(duì)照 | |
CSS 語法(不區(qū)分大小寫) | JavaScript 語法(區(qū)分大小寫) |
letter-spacing | letterSpacing |
line-break | lineBreak |
line-height | lineHeight |
text-align | textAlign |
text-decoration | textDecoration |
text-indent | textIndent |
text-justify | textJustify |
text-transform | textTransform |
vertical-align | verticalAlign |
規(guī)律:"-"去掉,并把-后面的首字母換成大寫 |
相關(guān)文章
淺析offsetLeft,Left,clientLeft之間的區(qū)別
這篇文章主要是對(duì)offsetLeft,Left,clientLeft之間的區(qū)別進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過來參考下想,希望對(duì)大家有所幫助2013-11-11JavaScript Break 和 Continue區(qū)別教程
JavaScript Break 和 Continue區(qū)別教程...2007-04-04JS數(shù)組遍歷中for,for in,for of,map,forEach各自的使用方法與優(yōu)缺點(diǎn)
這篇文章主要介紹了JS數(shù)組遍歷中for,for in,for of,map,forEach各自的使用方法與優(yōu)缺點(diǎn),需要的朋友可以參考下2022-01-01javascript實(shí)現(xiàn)的圖片切割多塊效果實(shí)例
這篇文章主要介紹了javascript實(shí)現(xiàn)的圖片切割多塊效果,涉及javascript操作圖片及css樣式的技巧,需要的朋友可以參考下2015-05-05JavaScript高級(jí)程序設(shè)計(jì)(第3版)學(xué)習(xí)筆記8 js函數(shù)(中)
接著看函數(shù)——這個(gè)具有魔幻色彩的對(duì)象。在上篇文章中說函數(shù)內(nèi)部屬性時(shí),還遺留了一個(gè)this內(nèi)部屬性沒有解釋,不過在說this之前,我想先說一說執(zhí)行環(huán)境和作用域的概念2012-10-10解析js中獲得父窗口鏈接getParent方法以及各種打開窗口的方法
本篇文章是對(duì)js中獲得父窗口鏈接getParent方法以及各種打開窗口的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06