• JS中style属性


    解决办法:
    1、先定义一个CSS规则,然后this.className=''
    2、document.getElementByIdx_x("a").style.cssText="border-collapse:collapse;border-spacing:1;border:1 solid #0B2565;background-color:white;color:black;text-align='center';"

    JS操作css的float属性的特殊写法
    使用js操作css属性的写法是有一定的规律的:

    1、对于没有中划线的css属性一般直接使用style.属性名即可。
    如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。

    2、对于含有中划线的css属性,将每个中划线去掉并将每个中划线后的第一个字符换成大写即可。
    如:obj.style.marginTop,obj.style.borderLeftWidth,obj.style.zIndex,obj.style.fontFamily等。

    这个规律我想大多数的前端开发者也都熟知。但在css中有一个特殊的属性其js使用方法比较特殊。
    这个特殊的属性就是:float。我们不能直接使用obj.style.float来使用,这样操作是无效的。

    其正确的使用方法是为:IE:obj.style.styleFloat,其他浏览器:obj.style.cssFloat。

    CSS 和 JavaScript 标签 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

    From:http://blog.sina.com.cn/s/blog_7de0b6230100z55x.html

  • 相关阅读:
    Cross-Site Scripting XSS 跨站攻击全攻略 分类: 系统架构 2015-07-08 12:25 21人阅读 评论(2) 收藏
    WAS集群:记一次Node Agent不活动问题解决过程
    Oracle RAC集群资料收集
    Linux使用 tar命令-g参数进行增量+差异备份、还原文件
    WAS7.0安装补丁升级程序无法替换文件 java/docs/autorun.inf解决办法
    Java程序员面试失败的5大原因
    Lemon OA第4篇:常用功能
    Lemon OA第3篇:核心功能
    Lemon OA第2篇:功能解析方法
    Activiti5小试牛刀demo流程
  • 原文地址:https://www.cnblogs.com/yinluhui0229/p/4777734.html
Copyright © 2020-2023  润新知