淘宝模板开发系列之DOM、CSS规范

DOM、CSS规范

目录

[隐藏]

页面结构

页面整体图示:

T1PCrgXlduXXaQP0oo-394-578.jpg

(1)页面包含页头、内容、页尾

(2)内容包含店铺页头、店铺内容、店铺页尾

(3)店铺内容包含多个布局,布局可以包含多个模块



对应的html结构:

T18hPgXcxvXXbVF.L4-486-346.jpg


说明:

  1. 开放的区域:

    此处发生改变,新规范将class=”tb-shop”去掉了,所以如果老模板以tb-shop开头书写的css样式将会失效;设计师模块class不允许以”tb-”开头。

  2. 命名空间:

    <div id="content" class=" tb-shop " ></div>,该设计区域的CSS样式有命名空间限制,需要以.tb-shop为namespace(命名空间)的名称。.tb-shop系统会自动给加上的,不建议开发者自己添加以.tb-shop开头的样式。

  3. CSS选择器规范:

    命名规范

  4. 此处发生细节变动,请设计师认真阅读:所有的选择器必须包含模块名class,例如.custom-module-name .title{}或者.col-sub .custom-module-name h3{}设计师不能添加id选择器;比如#box 将被过滤。
  5. 选择器不能使用.tb,.tb-shop 官方保留选择器;
  6. 除了.J_TBox和.J_TRegion以外,其它选择器只能包含小写字母(a-z),数字(0-9),点(.),下划线(_),横线(-),冒号(:)
  7. css 文件中选择器的属性及其值都支持大小写。
    支持的伪类(支持的伪类、支持的伪元素都未发生改变,详情可见如下链接: http://wiki.zx.taobao.com/index.php/DOM%E3%80%81CSS%E8%A7%84%E8%8C%83)
  8. :first-child
  9. :link
  10. :visited
  11. :hover
  12. :active
  13. :focus
    支持的伪元素
  14. :first-letter
  15. :first-line
  16. :before
  17. :after
  18. 特殊属性规则:

    margin属性

    -Margin取值
    SDK支持负数值
    内店自定义内容区不支持负数值
    外店自定义内容区不支持负数值
    完全自定义css支持负数值

    position属性
    position去掉fixed支持,模板两遍悬浮组件由官方提供。

    -position取值
    SDKabsolute | fixed | relative | static
    内店自定义内容区static
    外店自定义内容区static
    完全自定义cssabsolute | fixed | relative | static


    层级z-index控制
    此处发生重大变动,请设计师细心阅读:设计师允许使用的范围为1~99


    tag、class、id、style 的相关变动
    此处发生重大改变,请设计师细心阅读:

    a) 允许tag、class

    b) 不允许id、style、style标签



    淘宝页头说明L:

    店铺页头:页面中开放给设计师设计的店铺自己的页头。在简易模板中:C旺铺和商城对首页的店铺页头高度没有限制,但列表页和详情页仍然会有高度的限制。商城支持的最大高度为150px;C旺铺支持的最大高度为250px; 如果想设计的模板页头内容能在商城及C旺铺的所有页面通用,就最好把页头的内容控制在150px之内。商城列表页要支持250px;
    例:商城宝贝详情页店招部分的样式
    .ark .shop-banner {

       max-height: 150px;
       overflow: hidden;
       position: relative;
    

    }

区块(片区、坑)

  1. 区块html结构示意图:
    T1.J4ZXnVAXXXXXXXX-566-148.jpg

    说明:

    1. CSS规范:class="main-wrap J_TRegion" 中,J_TRegion是设计区域时必须添加的样式,其他的样式名如” main-wrap”是设计师可以自己添加的样式;
    2. 一个区块内可以添加多个模块。
  2. 区块示例
    • 页面显示:
      T1Cv8ZXgRbXXXXXXXX-497-422.jpg
    • Dom结构:
      T1N0BZXX4JXXXXXXXX-510-220.jpg

模块

T16LhZXntpXXXXXXXX-576-75.png

说明:

  1. CSS规范:class="box J_TBox" 中,J_TBox是设计模块时必须添加的样式名,其他的样式名如”box”是设计师可以自己添加的样式。
  2. 自定义样式.box{……}中的内容建议不要涉及float、position等这样对模块的位置进行定义的样式
  3. 建议不要用table来充当模块,否则效果将不明显或报错
  4. dom结构建议,如下图所示:
    T1q3tZXgFaXXXXXXXX-305-127.jpg

    绿色框里面的内容是模块本身的内容,建议:在模块内容和模块div标签本身再添加一层div,如红色框所示。

  5. 系统模块的样式可以通过如下地址访问可以看到 http://a.tbcdn.cn/p/shop/1.0/mods/s/shop-mods-min.css

    模块示例:

    1. 自动分类模块
      • 页面显示:
        T1bKhZXgXCXXXXXXXX-252-418.jpg
      • 页面代码:
        T1rvtZXlJmXXXXXXXX-521-289.jpg
    2. 搜索模块
      • 页面显示:
        T1uuXZXbJEXXXXXXXX-208-214.jpg
      • 页面代码:
        T1It8ZXXtFXXXXXXXX-542-248.jpg
    3. 宝贝排行榜
      • 页面显示:
        T1GMtZXgdaXXXXXXXX-207-264.jpg
      • 页面代码:
        T1B2FZXdJmXXXXXXXX-504-360.jpg
    4. 搜索列表页
      • 页面显示:
        T1su4ZXbJtXXXXXXXX-520-327.jpg
      • 页面代码:
        T1Y3XZXjxeXXXXXXXX-526-411.jpg

    布局

    说明:

    1. 淘宝店铺有系统布局
    2. 设计师在设计简易模板的时候,只能通过布局管理添加系统支持的布局。
    3. 设计师在设计sdk模板的时候,设计师可以设计自己的布局,系统对sdk模板的布局没有作任何限制。此时设计师可以参考系统布局设计自己的布局结构,也可以使用系统布局,然后覆盖系统的布局样式,设计自己的布局样式。

    淘宝系统布局

    系统提供的布局结构如下,总共有6种:

    T1ff0ZXlxiXXXXXXXX-533-195.jpg

    命名规则:

    1. 通栏布局(.grid-m)
    2. 两栏布局(.grid-sXm0)
    3. 三栏布局(.grid-sXm0eY)

      系统布局的样式在这个样式文件中http://a.tbcdn.cn/p/tshop/base.css

      命名含义如下:

      1. 当单元列的宽度为 40px 的倍数时,
        sX 表示 col-sub 的宽度 = X * 40 - 10,
        eY 表示 col-extra 的宽度 = Y * 40 - 10,
        m0 表示 col-main 的宽度 = 总宽度 - (X + Y) * 40,
        s m e 的顺序,可以按全排列排序,sXm0eY表示各列的排列顺序。

        比如:总宽为 950px 时,.grid-e6m0s5 表示 col-extra(230) | col-main(510) | col-sub(190).
        对应的样式为:
        .grid-e6m0s5 .main-wrap { margin: 0 200px 0 240px; }
        .grid-e6m0s5 .col-sub { width: 190px; margin-left: -190px; }
        .grid-e6m0s5 .col-extra { width: 230px; margin-left: -100%; }

      2. 当单元列的宽度不为40px的倍数时, sX和eY中的X 和 Y 直接表示宽度

        比如:总宽为 950px 时,.grid-s120m0e50 表示 col-sub(120) | col-main(760) | col-extra(50),
        对应的样式为:
        .grid-s120m0e50 .main-wrap { margin: 0 130px 0 60px; }
        .grid-s120m0e50 .col-sub { width: 120px; margin-left: -100%; }
        .grid-s120m0e50 .col-extra { width: 50px; margin-left: -50px; }

      自定义布局示例:

      1. 通栏和两栏(左右栏)

        说明:上层为通栏,下层为两栏(左右栏)

        页面显示:

        T1PK0ZXhXuXXXXXXXX-505-244.jpg

        页面代码:

        T1tKNZXnNwXXXXXXXX-408-217.jpg
      2. 三栏布局

        说明:总体分为两栏(左右栏):绿色框为左侧栏,红色框为主栏,红色框主栏又分为左右两栏,黑色框部分

        页面显示:

        T1i1xZXadAXXXXXXXX-502-156.jpg

        页面代码:

        T1Df4ZXlXhXXXXXXXX-501-163.jpg
        T1eLNZXgRkXXXXXXXX-466-187.jpg

      CSS白名单

      基本样式

      属性取值
      background-attachmentscroll | fixed
      background-clipborder-box | padding-box | content-box | no-clip
      background-colorcolor
      background-imagenone | url
      background-originborder | padding | content
      background-positionleft | center | right | top | center | bottom | length | percentage
      background-repeatrepeat | repeat-x | repeat-y | no-repeat
      boarderborder-width | border-style | border-color
      border-bottomborder-bottom-width | border-bottom-style | border-bottom-color
      border-bottom-colorcolor | transparent
      border-bottom-stylenone | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
      border-bottom-widththin | medium | thick | length
      border-colorcolor | transparent
      border-leftborder-left-width | border-left-style | border-left-color
      border-left-colorcolor | transparent
      border-left-stylenone | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
      border-left-widththin | medium | thick | length
      border-rightborder-right-width | border-right-style | border-right-color
      border-right-colorcolor | transparent
      border-right-stylenone | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
      border-right-widththin | medium | thick | length
      border-stylenone | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
      border-topborder-top-width border-top-style border-top-color
      border-top-colorColor | transparent
      border-top-stylenone | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
      border-top-widththin | medium | thick | length
      border-widthborder-top-width | border-right-width | border-bottom-width | border-left-width
      box-sizingcontent-box | border-box
      outlineoutline-color | outline-style | outline-width
      outline-colorcolor | invert
      outline-offsetlength
      outline-stylenone | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
      outline-widththin | medium | thick | length
      coloraqua | black | blue | fuchsia | gray | green | lime | maroon | navy | olive | orange | purple | red | silver | teal | white | yellow

      Transparent
      hex_number 规定颜色值为十六进制值的背景颜色(比如 #ff0000,只有3位和6位);rgb_number 规定颜色值为 rgb 代码的背景颜色(比如 rgb(255,0,0),0到255)

      directionltr | rtl
      letter-spacingnormal | length
      line-heightnormal | length | number | percentage
      text-alignleft | right | center | justify
      text-decorationnone | underline | overline | line-through | blink
      text-indentlength | percentage
      text-overflowclip | ellipsis
      text-shadowcolor | length | length | opacity
      text-transformnone | capitalize | uppercase | lowercase
      unicode-bidinormal | embed | bidi-override
      white-spacenormal | pre | nowrap | pre-wrap | pre-line
      word-spacingnormal | length
      word-breaknormal | break-all | keep-all
      word-wrapnormal | break-word
      writing-modelr-tb | tb-rl
      fontfont-style font-variant font-weight font-size/line-height font-family
      font-familyArial | Arial Narrow | Book Antiqua | Candara | Courier | Courier New | Helvetica | Monospace | Sans-Serif | Serif | Simsun | Tahoma | Verdana | 宋体 | 幼圆 | 新宋体 | 隶书 | 黑体| 微软雅黑 | 华文楷体 | 华文行楷
      font-sizexx-small | x-small | small | medium | large | x-large | xx-large | smaller | larger | length | percentage
      font-size-adjustnone | number
      font-stretchnormal | wider | narrower | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
      font-stylenormal | italic | oblique
      font-variantnormal | small-caps
      font-weightnormal | wider | narrower | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
      marginauto | length | percentage
      margin-bottomauto | length | percentage
      margin-leftauto | length | percentage
      margin-rightauto | length | percentage
      margin-topauto | length | percentage
      paddinglength | percentage
      padding-bottomlength | percentage
      padding-leftlength | percentage
      padding-rightlength | percentage
      padding-toplength | percentage
      list-style<ListStyle>
      list-style-typenone | disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-alpha | upper-alpha | lower-greek | lower-latin | upper-latin | hebrew | armenian | georgian | cjk-ideographic | hiragana | katakana | hiragana-iroha | katakana-iroha
      list-style-positioninside | outside
      list-style-imagenone | url
      marker-offsetauto | length
      content仅支持空串和\20
      counter-increment仅支持空串和\20
      counter-resetl仅支持空串和\20
      heightauto | length | percentage
      max-heightauto | length | percentage
      max-widthauto | length | percentage
      min-heightlength | percentage
      min-widthlength | percentage
      widthauto | length | percentage
      bottomauto | length | percentage
      clearleft | right | both | none
      clipauto | rect (top, right, bottom, left)
      cursordefault | auto | crosshair | pointer | move | e-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | text | wait | help | progress
      displaynone | block | inline | inline-block | list-item | run-in | compact | marker | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption
      floatleft | right | none
      leftauto | length | percentage
      opacitylength
      overflowvisible | hidden | scroll | auto
      overflow-xvisible | hidden | scroll | auto
      overflow-yvisible | hidden | scroll | auto
      positionabsolute | fixed | relative | static
      rightauto | length | percentage
      topauto | length | percentage
      vertical-alignbaseline | sub | super | top | text-top | middle | bottom | text-bottom | length | percentage
      visibilityvisible | hidden | collapse
      z-indexauto | int
      orphansInt
      page-break-afterauto | always | avoid | left | right
      page-break-beforeauto | always | avoid | left | right
      page-break-insideauto | avoid
      widowsint
      border-collapseseparate | collapse
      border-spacinglength length
      caption-sidetop | bottom
      empty-cellshide | show
      resizenone | both | horizontal | vertical
      table-layoutautomatic | fixed
      zoomnormal | number | percentage
      opacitynumber

      扩展样式

      属性取值
      border-radius<percentage> ]{1,4} [ /
      -moz-border-radius同border-radius
      -webkit-border-radius同border-radius
      border-top-left-radius<percentage> ] [ <length> | <percentage> ]?
      border-top-right-radius同border-top-left-radius
      border-bottom-right-radius同border-top-left-radius
      border-bottom-left-radius同border-top-left-radius
      -webkit-border-top-left-radius<percentage> ] [ <length> | <percentage> ]?
      -webkit-border-top-right-radius同border-top-left-radius m-color
      -webkit-border-bottom-left-radius同border-top-left-radius
      -moz-border-top-left-radius<percentage> ] [ <length> | <percentage> ]?
      -moz-border-top-right-radius同border-top-left-radius
      -moz-border-bottom-right-radius同border-top-left-radius
      -moz-border-bottom-left-radius同border-top-left-radius
      -moz-transition同transition
      -moz-transition-property同transition-property
      -moz-transition-duration同transition-timing-function
      -moz-transition-timing-function同transition-timing-function
      -moz-transition-delay同transition-delay
      -webkit-transition同transition
      -moz-transition-property同transition-property
      -moz-transition-duration同transition-duration
      -moz-transition-timing-function同transition-timing-function
      -moz-transition-delay同transition-delay
      -webkit-transition同transition
      -webkit-transition-property同transition-property
      -webkit-transition-duration同transition-duration
      -webkit-transition-timing-function同transition-timing-function
      -webkit-transition-delay同transition-delay
      -o-transition同transition
      -o-transition-property同transition-property
      -o-transition-duration同transition-duration
      -o-transition-timing-function同transition-timing-function
      -o-transition-delay同transition-delay
      box-shadow<shadow> [,<shadow>]*

      where <shadow> is defined as:inset? && [ <length> <length> <length>? <length>? <color>? ]

      -moz-box-shadow同box-shadow
      -webkit-box-shadow t同box-shadow
      -scrollbar-arrow-colorcolor
      -scrollbar-shadow-colorcolor
      -scrollbar-face-colorcolor
      -scrollbar-3dlight-colorcolor
      -scrollbar-darkshadow-colorcolor
      scrollbar-highlight-colorcolor
      -scrollbar-base-colorcolor
      -scrollbar-track-colorcolor
      -scrollbar-3d-light-colorcolor

      CSS hack

      为了能使设计师们sdk模板中的悬浮元素能很好地在ie6下显示,系统提供了ie6下position:fixed的支持(目前仅对sdk模板开放,开放起始日期为2011年4月14日),但是为了要使用系统提供的hack,设计师们需要按如下规范调整自己的模板:

      1. 不要在一个selector上同时写position:fixed; 和_position:absolute: 通过在module.xml中添加配置参数告知系统需要使用css hack(这个目前不需要做,后续要做,目前只要是sdk模板系统会进行position:fixed的css hack),如果让系统进行css hack修复position:fixed时,就不要再写_position:absolute了,否则系统不能再利用position:absolute进行ie6下的css hack
        例如:
        • 不支持的:.myww{position:fixed; right: 50px; bottom: 50px; _position: absolute;}
        • 支持的:.myww{position:fixed; right: 50px; bottom: 50px; }
      2. 不要在内联style内写position: fixed: 在内联style内写position: fixed,系统这样无法检测到,除position:fixed以外,其他的样式可以放在内联样式中
        • 不支持的:<divclass="myww J_TBox" style="position:fixed; right: 100px; top: 50px;"></div>
        • 支持的:<div> class="myww J_TBox" style="right: 100px; top: 50px;"> </div> <style>.myww{position:fixed;}</style>
      3. 应用position: fixed的element的right和bottom位置要注意,不要超过窗口的可视位置,若超过,用户在ie6下滑动滚动条,当滑动到页面底端的时候,滚动条不会停止滚动,而页面的内容即是空白。建议定位:可以通过right和bottom进行定位,当利用left和right进行定位时,最好不要让悬浮的元素的底端或右侧超出窗口一般的可视区域
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值