美文网首页
CSS 综合

CSS 综合

作者: 顺丰笑嘻嘻 | 来源:发表于2017-09-12 10:01 被阅读0次

1.平时写代码遵守的编码规范

  1. tab 用两个空格表示
  2. css的 :后加个空格, {前加个空格
  3. 每条声明后都加上分号
  4. 换行,而不是放到一行
  5. 颜色用小写,用缩写, #fff
  6. 小数不用写前缀, 0.5s -> .5s;0不用加单位
  7. 尽量缩写, margin: 5px 10px 5px 10px -> margin: 5px 10px
    参考代码规范连接:http://codeguide.bootcss.com/
    https://google.github.io/styleguide/htmlcssguide.xml

2.垂直居中有几种实现方式,给出代码范例

  1. 绝对定位实现居中
<head>
    <title></title>
    <style type="text/css">
        .ct {
            width:400px;
            height: 300px;
            position: relative;
            margin: 0 auto;
            background-color: #eee;
        }

        .box {
            width: 100px;
            height: 100px;
            position: absolute;
            background-color: red;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
        }
    </style>
</head>
<body>
 <div class="ct">
    <div class="box"></div>
 </div>
</body>
  1. vertical-align实现居中
<head>
    <title></title>
    <style type="text/css">
        .ct {
            width:400px;
            height: 300px;
            margin: 0 auto;
            background-color: #eee;
            text-align: center;
        }
        
        .ct::before {
            content: '';
            display: inline-block;
            height: 100%;
            vertical-align: middle;
        }

        .box {
            display: inline-block;
            width: 100px;
            height: 100px;
            background-color: red;
            vertical-align: middle;
        }

    </style>
</head>
<body>
 <div class="ct">
    <div class="box"></div>
 </div>
</body>
  1. table-cell实现居中
<head>
    <title></title>
    <style type="text/css">
        .ct {
            width:400px;
            height: 300px;
            background-color: #eee;
            display: table-cell;
            vertical-align: middle;
            text-align: center;
        }

        .box {
            display: inline-block;
            width: 100px;
            height: 100px;
            background-color: red;
        }

    </style>
</head>
<body>
 <div class="ct">
    <div class="box"></div>
 </div>
</body>

相关文章

  • CSS综合

    1、 前端编码规范 HTML书写规范 所有编码均遵循xhtml标准, 标签 & 属性 & 属性命名 必须由小写字母...

  • css综合

    1.说一说你平时写代码遵守的编码规范 1.1 标签语义化 1.2 tab用两个空格表示 1.3 不在自闭和的元素末...

  • CSS 综合

    1.平时写代码遵守的编码规范 tab 用两个空格表示 css的 :后加个空格, {前加个空格 每条声明后都加上分号...

  • CSS综合

    编码规范 命名技巧语义化语义化标签优先基于功能命名、基于内容命名、基于表现命名简略、明了、无后患命名范例所有命名都...

  • CSS 综合

    1. 说一说你平时写代码遵守的编码规范 命名规范命名用英文小写,中间用中划线链接命名用引号包裹命名体现功能,不涉及...

  • css综合

    1.编码规范 我平时写代码所遵循的规范如下: 命名都用小写,多个单词时用中划线连接。 命名用有意义的单词,做到看到...

  • css综合

    说一说你平时写代码遵守的编码规范 书写规范 tab用两个空格表示 css的:后加空格,{前加空格。 每条声明后都加...

  • css综合

    1.说一说你平时写代码遵守的编码规范 1.命名规范 语义化标签优先 基于功能、内容、表现命名 简单明了无歧义 2....

  • css综合

    HTML、CSS的一些编码规范 HTML:用两个空格表示缩进。嵌套元素应当缩进一次。对于属性的定义,确保全部使用双...

  • CSS综合

    1.说一说你平时写代码遵守的编码规范 命名技巧语义化标签优先基于功能命名,基于内容命名,基于表现命名简明、明了、无...

网友评论

      本文标题:CSS 综合

      本文链接:https://www.haomeiwen.com/subject/jgnqsxtx.html