当前位置:Gxlcms > html代码 > html和css的编码规范

html和css的编码规范

时间:2021-07-01 10:21:17 帮助过:22人阅读

HTML和CSS编码规范内容

一、HTML规范

二、CSS规范

三、注意事项:

四、常用的命名规则

五、CSS样式表文件命名

六、文件命名规则

一、HTML规范:

1.代码规范

  • 页面的第一行添加标准模式声明
  • 代码缩进:tab键设置四个空格(通常在软件右下角设置相应空格大小)
  • html中除了开头的DOC和 'UTF-8'或者head里特殊情况可以大写外,其他都为小写,css类都为小写
  • 建议为 html 根元素指定 lang 属性,从而为文档设置正确的语言 lang="zh-CN"
  • 不同doctype在不同浏览器下会触发不同的渲染模式
https://www.gxlcms.com/
https://www.gxlcms.com/html https://www.gxlcms.com/lang=https://www.gxlcms.com/"zh-CN">
  https://www.gxlcms.com/head>
      https://www.gxlcms.com/meta https://www.gxlcms.com/charset=https://www.gxlcms.com/"UTF-8">
      https://www.gxlcms.com/meta https://www.gxlcms.com/http-equiv=https://www.gxlcms.com/"X-UA-Compatible" https://www.gxlcms.com/content=https://www.gxlcms.com/"IE=Edge">
  https://www.gxlcms.com/head>
  ....
https://www.gxlcms.com/html>
  • 不要使用@import
    • 与 标签相比,@import 指令要慢很多,不光增加了额外的请求次数,还会导致不可预料的问题。替代办法有以下几种:
      • 使用多个 元素
      • 通过 Sass 或 Less 类似的 CSS 预处理器将多个 CSS 文件编译为一个文件
      • 通过 Rails、Jekyll 或其他系统中提供过 CSS 文件合并功能
https://www.gxlcms.com/
https://www.gxlcms.com/link https://www.gxlcms.com/rel=https://www.gxlcms.com/"stylesheet" https://www.gxlcms.com/href=https://www.gxlcms.com/"core.css">

https://www.gxlcms.com/
https://www.gxlcms.com/style>https://www.gxlcms.com/
  https://www.gxlcms.com/@https://www.gxlcms.com/import https://www.gxlcms.com/url(https://www.gxlcms.com/"more.css");
https://www.gxlcms.com/style>


引入 CSS 和 JavaScript 文件
  • 根据HTML5规范, 通常在引入CSS和JS时不需要指明 type,因为 text/css 和 text/javascript 分别是他们的默认值
https://www.gxlcms.com/
https://www.gxlcms.com/link https://www.gxlcms.com/rel=https://www.gxlcms.com/"stylesheet" https://www.gxlcms.com/href=https://www.gxlcms.com/"code-guide.css">

https://www.gxlcms.com/
https://www.gxlcms.com/style>https://www.gxlcms.com/
 https://www.gxlcms.com//* ... */
https://www.gxlcms.com/style>

https://www.gxlcms.com/
https://www.gxlcms.com/script https://www.gxlcms.com/src=https://www.gxlcms.com/"code-guide.js">https://www.gxlcms.com/https://www.gxlcms.com/script>

2.注释


  • 注意:--后不要留空格,若留空格,其他注释全加空格(方便后续程序开发)换句话说,注释要全局统一

eg:


为书写规范,最好每一个需要注释都需要开头和结尾,减少后续麻烦和错误。不要换行。CSS、JS注释亦然。



为书写规范,最好每一个需要注释都需要开头和结尾,减少后续麻烦和错误。不要换行。CSS、JS注释亦然。 https://www.gxlcms.com/span https://www.gxlcms.com/class=https://www.gxlcms.com/"avatar"> https://www.gxlcms.com/img https://www.gxlcms.com/src=https://www.gxlcms.com/"..."> https://www.gxlcms.com/span> https://www.gxlcms.com/ https://www.gxlcms.com/img https://www.gxlcms.com/class=https://www.gxlcms.com/"avatar" https://www.gxlcms.com/src=https://www.gxlcms.com/"...">

6.布尔型属性

  • 布尔型属性可以在声明时不赋值。XHTML 规范要求为其赋值,但是 HTML5 规范不需要。换句话说,不用赋值。
https://www.gxlcms.com/input https://www.gxlcms.com/type=https://www.gxlcms.com/"text" https://www.gxlcms.com/disabled>

https://www.gxlcms.com/input https://www.gxlcms.com/type=https://www.gxlcms.com/"checkbox" https://www.gxlcms.com/value=https://www.gxlcms.com/"1" https://www.gxlcms.com/checked>

https://www.gxlcms.com/select>
 https://www.gxlcms.com/option https://www.gxlcms.com/value=https://www.gxlcms.com/"1" https://www.gxlcms.com/selected>1https://www.gxlcms.com/option>
https://www.gxlcms.com/select>

二、css规范

1、语法

1.1、缩进
[强制]使用 https://www.gxlcms.com/4 个空格做为一个缩进层级,不允许使用 https://www.gxlcms.com/2 个空格 或 tab 字符。  

1.2、空格

  • [强制]为了代码易读性,每个声明块的左花括号前添加一个空格
  • [强制]每条声明语句的" : "后应该插一个空格
  • [强制]属性多值每个逗号后应该插入空格 eg:box-shadow,border-image
  • [强制]不要在rgb()、rgba()、hsl()、hsla() 或 rect() 值的内部的逗号后面插入空格
    对于属性值或颜色参数,省略小于 1 的小数前面的 0 (例如,.5 代替 0.5;-.5px 代,替 -0.5px)

1.3、选择器

  • [强制]为选择器分组时,将单独的选择器单独存放在一行 eg:tr,td{}
  • [强制] >、+、~ 选择器的两边各保留一个空格。
  • [强制]为选择器中的属性添加双引号 不允许单引号
    例如,input[type="text"]。只有在某些情况下是可选的,但是,为了代码的一致性,建议都加上双引号。
  • [强制] 如无必要,不得为 id、class 选择器添加类型选择器进行限定。
  • [建议] 选择器的嵌套层级应不大于 3 级,位置靠后的限定条件应尽可能精确。
    eg:

    https://www.gxlcms.com//* good */  
    https://www.gxlcms.com/#error,  
    https://www.gxlcms.com/.danger-message https://www.gxlcms.com/{
       https://www.gxlcms.com/https://www.gxlcms.com/font-color:https://www.gxlcms.com/ https://www.gxlcms.com/#c00;
    }
    https://www.gxlcms.com/#username https://www.gxlcms.com/input https://www.gxlcms.com/{}
    https://www.gxlcms.com/.comment https://www.gxlcms.com/.avatar https://www.gxlcms.com/{}
    
    https://www.gxlcms.com//* bad */
    https://www.gxlcms.com/dialoghttps://www.gxlcms.com/#error,
    https://www.gxlcms.com/phttps://www.gxlcms.com/.danger-message https://www.gxlcms.com/{
       https://www.gxlcms.com/https://www.gxlcms.com/font-color:https://www.gxlcms.com/ https://www.gxlcms.com/#c00;
    }
    https://www.gxlcms.com/.page https://www.gxlcms.com/.header https://www.gxlcms.com/.login https://www.gxlcms.com/#username https://www.gxlcms.com/input https://www.gxlcms.com/{}
    https://www.gxlcms.com/.comment https://www.gxlcms.com/div * https://www.gxlcms.com/{}
    

1.4、行

  • [强制]每行不得超过 120 个字符,除非单行不可分割。
  • [强制]声明块右花括号应当成行
  • [建议] 对于超长的样式,在样式值的 空格 处或 , 后换行,建议按逻辑分组。
    eg:background:url(....) 此处应有换行 no-repeat;

1.5、属性

  • [强制] 属性定义必须另起一行。
  • [强制] 属性定义后必须以分号结尾。
    • 即每条声明应单独成行,以分号结尾
  • [建议] 在可以使用缩写的情况下,尽量使用属性缩写。
    eg:font: 12px/1.5 arial, sans-serif;

1.6、前缀

  • [强制] 带私有前缀的属性由长到短排列,按冒号位置对齐。
  • [建议] 可以给选择器添加一个表示状态的前缀,让语义更明了,比如下图是添加了“.is-”前缀。

1.7、简写

  • 十六进制值应该全部小写,尽可能简写 eg:#fff
  • .避免为 0 值指定单位
    例如,用 margin: 0; 代替 margin: 0px;
https://www.gxlcms.com//* Bad CSS */
https://www.gxlcms.com/main>https://www.gxlcms.com/nav https://www.gxlcms.com/{
   https://www.gxlcms.com/https://www.gxlcms.com/padding:https://www.gxlcms.com/ https://www.gxlcms.com/10px;
}
https://www.gxlcms.com/.selector, https://www.gxlcms.com/.selector-secondary, https://www.gxlcms.com/.selectorhttps://www.gxlcms.com/[type=text] https://www.gxlcms.com/{  

   https://www.gxlcms.com/https://www.gxlcms.com/padding:https://www.gxlcms.com/https://www.gxlcms.com/15px;  
    https://www.gxlcms.com/https://www.gxlcms.com/margin:https://www.gxlcms.com/https://www.gxlcms.com/0px https://www.gxlcms.com/0px https://www.gxlcms.com/15px; 
   https://www.gxlcms.com/https://www.gxlcms.com/background-color:https://www.gxlcms.com/https://www.gxlcms.com/rgba(https://www.gxlcms.com/0, https://www.gxlcms.com/0, https://www.gxlcms.com/0, https://www.gxlcms.com/0.5);
   https://www.gxlcms.com/https://www.gxlcms.com/box-shadow:https://www.gxlcms.com/https://www.gxlcms.com/0px https://www.gxlcms.com/1px https://www.gxlcms.com/2px https://www.gxlcms.com/#CCC,inset https://www.gxlcms.com/0 https://www.gxlcms.com/1px https://www.gxlcms.com/0 https://www.gxlcms.com/#FFFFFF 
}  
https://www.gxlcms.com/.selector, https://www.gxlcms.com/.selector-secondary, https://www.gxlcms.com/.selectorhttps://www.gxlcms.com/[type=text] https://www.gxlcms.com/{https://www.gxlcms.com/https://www.gxlcms.com/padding:https://www.gxlcms.com/https://www.gxlcms.com/15px;https://www.gxlcms.com/https://www.gxlcms.com/margin:https://www.gxlcms.com/https://www.gxlcms.com/0px https://www.gxlcms.com/0px https://www.gxlcms.com/15px;}

https://www.gxlcms.com//* Good CSS */ 
https://www.gxlcms.com/main > https://www.gxlcms.com/nav https://www.gxlcms.com/{
   https://www.gxlcms.com/https://www.gxlcms.com/padding:https://www.gxlcms.com/ https://www.gxlcms.com/10px;
}
https://www.gxlcms.com/.selector,  
https://www.gxlcms.com/.selector-secondary,  
https://www.gxlcms.com/.selectorhttps://www.gxlcms.com/[type="text"] https://www.gxlcms.com/{  
   https://www.gxlcms.com/https://www.gxlcms.com/padding:https://www.gxlcms.com/ https://www.gxlcms.com/15px;  
   https://www.gxlcms.com/https://www.gxlcms.com/margin-bottom:https://www.gxlcms.com/ https://www.gxlcms.com/15px; 
   https://www.gxlcms.com/https://www.gxlcms.com/background-color:https://www.gxlcms.com/ https://www.gxlcms.com/rgba(https://www.gxlcms.com/0,https://www.gxlcms.com/0,https://www.gxlcms.com/0,.https://www.gxlcms.com/5);
   https://www.gxlcms.com/https://www.gxlcms.com/background:https://www.gxlcms.com/
     transparent https://www.gxlcms.com/url(aVeryVeryVeryLongUrlIsPlacedHere)
       no-repeat https://www.gxlcms.com/0 https://www.gxlcms.com/0;
   https://www.gxlcms.com/https://www.gxlcms.com/box-shadow:https://www.gxlcms.com/ https://www.gxlcms.com/0 https://www.gxlcms.com/1px https://www.gxlcms.com/2px https://www.gxlcms.com/#ccc, inset https://www.gxlcms.com/0 https://www.gxlcms.com/1px https://www.gxlcms.com/0 https://www.gxlcms.com/#fff;
}  

2.注释

  • /* 注释内容 */
    注意:*后不要留空格,若留空格,其他注释全加空格(方便后续程序开发)换句话说,注释要全局统一

eg: /* S 注释内容 */

为书写规范,最好每一个需要注释都需要开头和结尾,减少后续麻烦和错误。不要翻行。CSS、JS注释亦然。

/* E 注释内容 */

3.命名规范

  • 1.应用 英文缩写命名法,杜绝用中文拼音或者中文拼音缩写(这是因为英文具有简易性,必要时可上网搜索国际缩写英文)
  • 2. 只能出现小写字符或者中划线(破折号符),不用下划线,驼峰命名法。
    eg: .btn 或者 .btn-danger
  • 3.避免过度任意的简写。.btn 代表 button,但是 .s 不能表达任何意思
  • 4.class 名称应当尽可能短,并且意义明确。
  • 使用有意义的名称。使用有组织的或目的明确的名称,不要使用表现形式(presentational)的名称。
  • 基于最近的父 class 或基本(base) class 作为新 class 的前缀。
  • 使用 .js-* class 来标识行为(与样式相对),并且不要将这些 class 包含到 CSS 文件中。

在为 Sass 和 Less 变量命名是也可以参考上面列出的各项规范。

https://www.gxlcms.com//* Bad example */
.t { ... }
.red { ... }
.header { ... }

https://www.gxlcms.com//* Good example */
.tweet { ... }
.important { ... }
.tweet-header { ... }

4.选择器

  • 对于通用元素使用 class ,这样利于渲染性能的优化。
  • 对于经常出现的组件,避免使用属性选择器(例如,[class="..."])。浏览器的性能会受到这些因素的影响。
  • 选择器要尽可能短,并且尽量限制组成选择器的元素个数,建议不要超过 3 。
  • 只有在必要的时候才将 class 限制在最近的父元素内(也就是后代选择器)(例如,不使用带前缀的 class 时 -- 前缀类似于命名空间)。
https://www.gxlcms.com//* Bad example */
span { ... }
.page-container https://www.gxlcms.com/#stream .stream-item .tweet .tweet-header .username { ... }
.avatar { ... }

https://www.gxlcms.com//* Good example */
.avatar { ... }
.tweet-header .username { ... } https://www.gxlcms.com///不要超过3个
.tweet .avatar { ... }

5.声明顺序

5.1. 相关的属性声明应当归为一组,并按照下面的顺序排列:
https://www.gxlcms.com/* Positioning
https://www.gxlcms.com/* Box model
https://www.gxlcms.com/* Typographic
https://www.gxlcms.com/* Visual  

由于定位(positioning)可以从正常的文档流中移除元素,并且还能覆盖盒模型(box model)相关的样式,因此排在首位。盒模型排在第二位,因为它决定了组件的尺寸和位置。

其他属性只是影响组件的内部(inside)或者是不影响前两组属性,因此排在后面。 eg:

https://www.gxlcms.com/.declaration-order https://www.gxlcms.com/{
  https://www.gxlcms.com//* Positioning */
  https://www.gxlcms.com/https://www.gxlcms.com/position:https://www.gxlcms.com/ absolute;
  https://www.gxlcms.com/https://www.gxlcms.com/top:https://www.gxlcms.com/ https://www.gxlcms.com/0;
  https://www.gxlcms.com/https://www.gxlcms.com/right:https://www.gxlcms.com/ https://www.gxlcms.com/0;
  https://www.gxlcms.com/https://www.gxlcms.com/bottom:https://www.gxlcms.com/ https://www.gxlcms.com/0;
  https://www.gxlcms.com/https://www.gxlcms.com/left:https://www.gxlcms.com/ https://www.gxlcms.com/0;
  https://www.gxlcms.com/https://www.gxlcms.com/z-index:https://www.gxlcms.com/ https://www.gxlcms.com/100;

  https://www.gxlcms.com//* Box-model */  https://www.gxlcms.com/https://www.gxlcms.com/display:https://www.gxlcms.com/ block;
  https://www.gxlcms.com/https://www.gxlcms.com/float:https://www.gxlcms.com/ right;
  https://www.gxlcms.com/https://www.gxlcms.com/width:https://www.gxlcms.com/ https://www.gxlcms.com/100px;
  https://www.gxlcms.com/https://www.gxlcms.com/height:https://www.gxlcms.com/ https://www.gxlcms.com/100px;

  https://www.gxlcms.com//* Typography */
  https://www.gxlcms.com/https://www.gxlcms.com/font:https://www.gxlcms.com/ normal https://www.gxlcms.com/13px https://www.gxlcms.com/"Helvetica Neue", sans-serif;
  https://www.gxlcms.com/https://www.gxlcms.com/line-height:https://www.gxlcms.com/ https://www.gxlcms.com/1.5;
  https://www.gxlcms.com/https://www.gxlcms.com/color:https://www.gxlcms.com/ https://www.gxlcms.com/#333;
  https://www.gxlcms.com/https://www.gxlcms.com/text-align:https://www.gxlcms.com/ center;

  https://www.gxlcms.com//* Visual */
  https://www.gxlcms.com/https://www.gxlcms.com/background-color:https://www.gxlcms.com/ https://www.gxlcms.com/#f5f5f5;
  https://www.gxlcms.com/https://www.gxlcms.com/border:https://www.gxlcms.com/ https://www.gxlcms.com/1px solid https://www.gxlcms.com/#e5e5e5;
  https://www.gxlcms.com/https://www.gxlcms.com/border-radius:https://www.gxlcms.com/ https://www.gxlcms.com/3px;

  https://www.gxlcms.com//* Misc */
  https://www.gxlcms.com/https://www.gxlcms.com/opacity:https://www.gxlcms.com/ https://www.gxlcms.com/1;
}

5.2.设置盒子模型 - 是否脱离标准(子絶父相)- 其他属性

注意兼容性写法(纯属个人习惯)

  • 盒子模型
    • 1.设置是否需要浮动元素 或者 转块(float,display)
    • 2.设置盒子边框、背景颜色、字体颜色(border,background,font,color)
    • 3.设置宽高大小(width,height)
    • 4.文字垂直居中(line-hight,text-align,vertical-align等等)
    • 5.设置margin、padding值
  • 标准流(子絶父相)
    • position :relative、absolute、static、fixed
    • left/top/right/bottom
    • z-index
  • 其他属性
    • opcaity、cursor等
  • css3新属性
    • transition、transform、animation等

每个范围可由首字母开头为排序:
eg:盒子模型中的第2条中,可由background,border,color等首字母为先排序; 但有些例外,如position肯定排先,后定义left等方向位属性


ps:需要用到媒体查询,将媒体查询放在尽可能相关规则的附近


eg:

.declaration-order {
  display: block;
  https://www.gxlcms.com/float: right;  
  background-color: https://www.gxlcms.com/#f5f5f5;
  border: https://www.gxlcms.com/1px solid https://www.gxlcms.com/#e5e5e5;
  border-radius: https://www.gxlcms.com/3px;
  color: https://www.gxlcms.com/#https://www.gxlcms.com/333;
  font: normal https://www.gxlcms.com/13px https://www.gxlcms.com/"Helvetica Neue", sans-serif;  

  width: https://www.gxlcms.com/100px;
  height: https://www.gxlcms.com/100px;
  text-align: center;
  line-height: https://www.gxlcms.com/100px;

  margin: https://www.gxlcms.com/0 https://www.gxlcms.com/auto;
  padding: https://www.gxlcms.com/10px https://www.gxlcms.com/0;  

  position: absolute;
  top: https://www.gxlcms.com/0;
  right: https://www.gxlcms.com/0;
  bottom: https://www.gxlcms.com/0;
  left: https://www.gxlcms.com/0;
  z-index: https://www.gxlcms.com/100;
  opacity: https://www.gxlcms.com/1;

  transtion: all https://www.gxlcms.com/.5s ease https://www.gxlcms.com/0s;
  animation: name initial https://www.gxlcms.com/2s;
}
@keyframes name{
    https://www.gxlcms.com/0%{}
    https://www.gxlcms.com/100{}
    https://www.gxlcms.com////
    from{}
    to{}
}
@https://www.gxlcms.com/media screen https://www.gxlcms.com/and https://www.gxlcms.com/(min-width) https://www.gxlcms.com/and https://www.gxlcms.com/(max-width){
    and左右之间要留空格
}

5.3.按照首字母排列顺序编写

注意事项:

1. 尽量不使用 !important 声明。

  • [建议] 当需要强制指定样式且不允许任何场景覆盖时,通过标签内联和 !important 定义样式。

2.媒体查询(Media query)的位置

  • 将媒体查询放在尽可能相关规则的附近。不要将他们打包放在一个单一样式文件中或者放在文档底部。如果你把他们分开了,将来只会被大家遗忘。

3.带前缀的属性

  • 当使用特定厂商的带有前缀的属性时,通过缩进的方式,让每个属性的值在垂直方向对齐,这样便于多行编辑。

    在 Textmate 中,使用 Text → Edit Each Line in Selection (⌃⌘A)。在 Sublime Text 2 中,使用 Selection → Add Previous Line (⌃⇧↑) 和 Selection → Add Next Line (⌃⇧↓)。

    Prefixed properties */ lector { webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15); box-shadow: 0 1px 2px rgba(0,0,0,.15);


4.单行规则声明

  • 对于只包含一条声明的样式,为了易读性和便于快速编辑,建议将语句放在同一行 (能仔细分析,检测错误)

5.简写形式的属性声明

  • 在需要显示地设置所有值的情况下,应当尽量限制使用简写形式的属性声明。常见的滥用简写属性声明的情况如下:
    • padding
    • margin
    • font
    • background
    • border
    • border-radius
https://www.gxlcms.com//* Bad example */
https://www.gxlcms.com/.element https://www.gxlcms.com/{
  https://www.gxlcms.com/https://www.gxlcms.com/margin:https://www.gxlcms.com/ https://www.gxlcms.com/0 https://www.gxlcms.com/0 https://www.gxlcms.com/10px;
  https://www.gxlcms.com/https://www.gxlcms.com/background:https://www.gxlcms.com/ red;
  https://www.gxlcms.com/https://www.gxlcms.com/background:https://www.gxlcms.com/ https://www.gxlcms.com/url(https://www.gxlcms.com/"image.jpg");
  https://www.gxlcms.com/https://www.gxlcms.com/border-radius:https://www.gxlcms.com/ https://www.gxlcms.com/3px https://www.gxlcms.com/3px https://www.gxlcms.com/0 https://www.gxlcms.com/0;
}

https://www.gxlcms.com//* Good example */
https://www.gxlcms.com/.element https://www.gxlcms.com/{
  https://www.gxlcms.com/https://www.gxlcms.com/margin-bottom:https://www.gxlcms.com/ https://www.gxlcms.com/10px;
  https://www.gxlcms.com/https://www.gxlcms.com/background-color:https://www.gxlcms.com/ red;
  https://www.gxlcms.com/https://www.gxlcms.com/background-image:https://www.gxlcms.com/ https://www.gxlcms.com/url(https://www.gxlcms.com/"image.jpg");
  https://www.gxlcms.com/https://www.gxlcms.com/border-top-left-radius:https://www.gxlcms.com/ https://www.gxlcms.com/3px;
  https://www.gxlcms.com/https://www.gxlcms.com/border-top-right-radius:https://www.gxlcms.com/ https://www.gxlcms.com/3px;
}

6.Less 和 Sass 中的嵌套

  • 避免非必要的嵌套。这是因为虽然你可以使用嵌套,但是并不意味着应该使用嵌套。只有在必须将样式限制在父元素内(也就是后代选择器),并且存在多个需要嵌套的元素时才使用嵌套。
// Without nesting
.https://www.gxlcms.com/table > thead > tr > th { … }
.https://www.gxlcms.com/table > thead > tr > td { … }

// With nesting
.https://www.gxlcms.com/table > thead > tr {
  > th { … }
  > td { … }
}

了解更多请点击,本文更多参照此文章

常用的命名规则

class的命名

用中划线 ' - '

头:header
内容:content/container
尾:footer
导航:nav
侧栏:sidebar
栏目:column
页面外围控制整体佈局宽度:wrapper
左右中:https://www.gxlcms.com/left https://www.gxlcms.com/right center
登录条:loginbar
标志:logo
广告:banner
页面主体:main
热点:hot
新闻:news
下载:download
子导航:subnav
菜单:menu
子菜单:submenu
搜索:search
友情链接:friendlink
页脚:footer
版权:copyright
滚动:scroll
内容:content
标签:tags
文章列表:list
提示信息:msg
小技巧:tips
栏目标题:title
加入:joinus
指南:guide
服务:service
注册:regsiter
状态:status
投票:vote
合作伙伴:partner

Id的命名:

用下划线 ' _ '

1)页面结构

容器: container 页头:header 内容:content/container 页面主体:main 页尾:footer 导航:nav 侧栏:sidebar 栏目:column 页面外围控制整体佈局宽度:wrapper 左右中:left right center

(2)导航

导航:nav 主导航:mainnav 子导航:subnav 顶导航:topnav 边导航:sidebar 左导航:leftsidebar 右导航:rightsidebar 菜单:menu 子菜单:submenu 标题: title 摘要: summary

(3)功能

标志:logo 广告:banner 登陆:login 登录条:loginbar 注册:register 搜索:search 功能区:shop 标题:title 加入:joinus 状态:status 按钮:btn 滚动:scroll 标籤页:tab 文章列表:list 提示信息:msg 当前的: current 小技巧:tips 图标: icon 注释:note 指南:guild 服务:service 热点:hot 新闻:news 下载:download 投票:vote 合作伙伴:partner 友情链接:link 版权:copyright

CSS样式表文件命名

主要的 https://www.gxlcms.com/masterhttps://www.gxlcms.com/.css
模块 https://www.gxlcms.com/modulehttps://www.gxlcms.com/.css
基本共用 https://www.gxlcms.com/basehttps://www.gxlcms.com/.css
布局、版面 https://www.gxlcms.com/layouthttps://www.gxlcms.com/.css
主题 https://www.gxlcms.com/themeshttps://www.gxlcms.com/.css
专栏 https://www.gxlcms.com/columnshttps://www.gxlcms.com/.css
文字 https://www.gxlcms.com/fonthttps://www.gxlcms.com/.css
表单 https://www.gxlcms.com/formshttps://www.gxlcms.com/.css
补丁 https://www.gxlcms.com/mendhttps://www.gxlcms.com/.css
打印 https://www.gxlcms.com/printhttps://www.gxlcms.com/.css

文件命名规则

项目命名 全部采用小写方式,以下划线分隔 例:my_project_name 目录命名

参照项目命名规则;

有复数结构时,要采用复数命名法。

例:scripts, styles, images, data_models JS文件命名

参照项目命名规则。

例:account_model.js CSS, SCSS文件命名

参照项目命名规则。

例:retina_sprites.scss HTML文件命名

参照项目命名规则。

例:error_report.html

人气教程排行