博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CSS基础构架及标准
阅读量:5914 次
发布时间:2019-06-19

本文共 2450 字,大约阅读时间需要 8 分钟。

CSS Architecture

base.less - Provide style reset and atomic functions

  • the project module(.epc-page) styles
  • body styles
  • font-family
  • font-size
  • color
  • width factor
  • common width

common.less - Abstract the component styles common to the site.

  • page layout
  • responsive width
  • common component styles

page.less - A particular style of a particular page.

  • All function pages must have their scope
  • Defining global styles is prohibited

CSS Written Order

  • Location attribute (position, top, right, z-index, display, float ...)
  • Size (width, height, padding, margin ...)
  • Text series (font, line-height, letter-spacing, color- text-align ...)
  • Background (background, border ...)
  • Other (animation, transition ...)

CSS Written Standard

abbreviation

CSS has some properties that can be abbreviated, such as padding, margin, font, etc. This streamlines the code while improving the user's reading experience.

clipboard.png

Remove the "0" before the decimal point

clipboard.png

Abbreviated name-Easy to understand, but not casual.

clipboard.png

Hyphenated CSS selector naming convention

Long names or phrases can use the middle dash to name selectors.

It is not recommended to use the "_" underscore to name the CSS selector. Why?

  1. Press the shift key a little while typing.
  2. Browser compatibility issues (named after a selector using _tips, for example, is invalid in IE6)
  3. Well-distributed JavaScript variable naming (JS variable name is "_")

Do not use id freely

The ID is unique and high priority, so we should use it on demand.

Less usage

Variables

@nice-blue: #5B83AD;#header {    color: @nice-blue;}

We can define the font, size, color, etc. as constants.

Mixins

.bordered {    border-top: dotted 1px black;    border-bottom: solid 2px black;}.post a {    color: red;    .bordered;}

We can transfer variables, Usage is similar to functions

Nested Rules

.header {    color: black;}.header .navigation {    font-size: 12px;}.header-logo {    width: 300px;}.header {    .navigation {        font-size: 12px;    }    &-logo {        width: 300px;    }}

Directives such as media or keyframe can be nested in the same way as selectors.

Namespaces and Accessors

#bundle {    .button {        display: block;        border: 1px solid black;        background-color: grey;        &:hover {            background-color: white        }    }    .tab {    ...    }    .citation {    ...    }}

We should use the component's namespace and scope.

Scope

@var: red;#page {   @var: white;   #header {      color: @var; // white   }}

转载地址:http://yiwvx.baihongyu.com/

你可能感兴趣的文章
更好使用jQuery的8个小技巧
查看>>
推荐系统实践 - 第1章
查看>>
linux文件操作
查看>>
BZOJ 1058 报表统计(splay+set)
查看>>
ogre相关
查看>>
python 闭包
查看>>
Google攻击最新调查结果曝光:密码系统受害
查看>>
Linux进程托管与守护进程设置
查看>>
自定义类和集合
查看>>
Android Mediaplayer解读
查看>>
Processing的代码编写流程
查看>>
转[]面向对象基础(概念、特征、要素)
查看>>
GLSL学习笔记 [转]
查看>>
C#方法参数传递-输出参数out关键字
查看>>
IT项目各岗位职责 (转)
查看>>
fstab 介绍
查看>>
jquery.validate使用攻略
查看>>
如果将彩色图像和灰度图像一起放进 CNN 中去,会是什么结果?
查看>>
小米note3的开发者选项在哪里?怎么进入开发者模式?如何显示布局边界?
查看>>
postman添加权限验证
查看>>