javascript
javascript修改CSS
1.js修改單個元素的css屬性????
document.getElementByIdx('obj').className=”…”,
document.getElementByIdx('obj').style.backgroundColor=”#003366″,
2.js修改整個頁面的css屬性?????
<link rel = "stylesheet"type="text/css" id="css" href="firefox.css"/>
<spanon click="javascript:document.getElementByIdx('css').href ='ie.css'"></span>
3.js和css的style屬性對照表
盒子標簽和屬性對照
CSS語法 (不區分大小寫) JavaScript語法 (區分大小寫)
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
?
顏色和背景標簽和屬性對照
CSS語法 (不區分大小寫) JavaScript語法 (區分大小寫)
background background
background-attachment backgroundAttachment
background-color backgroundColor
background-image backgroundImage
background-position backgroundPosition
background-repeat backgroundRepeat
color color
?
樣式標簽和屬性對照
CSS語法 (不區分大小寫) JavaScript語法 (區分大小寫)
display display
list-style-type listStyleType
list-style-image listStyleImage
list-style-position listStylePosition
list-style listStyle
white-space whiteSpace
?
文字樣式標簽和屬性對照
CSS語法 (不區分大小寫) JavaScript語法 (區分大小寫)
font font
font-family fontFamily
font-size fontSize
font-style fontStyle
font-variant fontVariant
font-weight fontWeight
?
文本標簽和屬性對照
CSS語法 (不區分大小寫) JavaScript語法 (區分大小寫)
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
4.引起css改變的js事件
HTML 4.0 的新特性之一是有能力使 HTML事件觸發瀏覽器中的動作(action),比如當用戶點擊某個 HTML 元素時啟動一段JavaScript。下面是一個屬性列表,這些屬性可插入 HTML 標簽來定義事件動作。
FF: Firefox, N:Netscape, IE: Internet Explorer
?
| onabort | 圖像加載被中斷 | 1 | 3 | 4 |
| onblur | 元素失去焦點 | 1 | 2 | 3 |
| onchange | 用戶改變域的內容 | 1 | 2 | 3 |
| onclick | 鼠標點擊某個對象 | 1 | 2 | 3 |
| ondblclick | 鼠標雙擊某個對象 | 1 | 4 | 4 |
| onerror | 當加載文檔或圖像時發生某個錯誤 | 1 | 3 | 4 |
| onfocus | 元素獲得焦點 | 1 | 2 | 3 |
| onkeydown | 某個鍵盤的鍵被按下 | 1 | 4 | 3 |
| onkeypress | 某個鍵盤的鍵被按下或按住 | 1 | 4 | 3 |
| onkeyup | 某個鍵盤的鍵被松開 | 1 | 4 | 3 |
| onload | 某個頁面或圖像被完成加載 | 1 | 2 | 3 |
| onmousedown | 某個鼠標按鍵被按下 | 1 | 4 | 4 |
| onmousemove | 鼠標被移動 | 1 | 6 | 3 |
| onmouseout | 鼠標從某元素移開 | 1 | 4 | 4 |
| onmouseover | 鼠標被移到某元素之上 | 1 | 2 | 3 |
| onmouseup | 某個鼠標按鍵被松開 | 1 | 4 | 4 |
| onreset | 重置按鈕被點擊 | 1 | 3 | 4 |
| onresize | 窗口或框架被調整尺寸 | 1 | 4 | 4 |
| onselect | 文本被選定 | 1 | 2 | 3 |
| onsubmit | 提交按鈕被點擊 | 1 | 2 | 3 |
| onunload | 用戶退出頁面 | 1 | 2 | 3 |
總結
以上是生活随笔為你收集整理的javascript修改CSS的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 纯CSS画的基本图形(矩形、圆形、三角形
- 下一篇: 快速上手RaphaelJS--Rapha