CSS基础

  • 选择器

    选择器 {
        属性:值;
        属性:值;
    }
    
    • 用于匹配HTML元素

    • 有不同的选择规则

    • 可以叠加

    • 存在优先级问题

      <!DOCTYPE html>
      <html>
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <meta http-equiv="X-UA-Compatible" content="ie=edge">
          <title>basic</title>
          <style>
              #test1{
                  color:red;
              }
              #test1.test1{
                  color:blue;
              }
      
              .test2{
                  color:red;
              }
              div.test2{
                  color:blue;
              }
      
              #test3{
                  color:red;
              }
              .c1.c2.c3.c4.c5.c6.c7.c8.c9.c10.c11{
                  color:blue;
              }
          </style>
      </head>
      <body class="body" id="body">
          <div id="test1" class="test1">test1</div>
          <div class="test2">test2</div>
          <div id="test3" class="c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11">
              test3
          </div>
      </body>
      </html>
      
    • !important使得元素权重最高

  • 非布局样式

    • 字体
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>fonts</title>
        <style>
            body{
                /* font-family: "monaco"; */
                /* font-family: "monaco", "PingFang SC"; */
                font-family: "aaaaa", "monaco", "PingFang SC";
            }
            .chinese{
                font-family: "PingFang SC", "Microsoft Yahei", monospace;
                /* font-family: "Microsoft Yahei", serif; */
                /* font-family: "serif"; */
            }
            .weight{
                font-weight: bold;
                font-weight: bolder;
                font-weight: lighter;
                font-weight: normal;
                font-weight: 100;
            }
            /*自定义字体引入*/
            @font-face {
                font-family: "IF";
                src: url("./IndieFlower.ttf");
            }
            .custom-font{
                font-family: IF;
            }
        </style>
    </head>
    <body class="body" id="body">
        Hello world 你好,世界
        <div class="chinese">你好</div>
        <!-- <div class="weight">你好 Hello World</div> -->
        <div class="custom-font">你好 Hello World</div>
    </body>
    </html>
    
    • iconfont

    • 行高

      • 行高的构成

        • 是lineBox的高度
        • lineBox的高度是由其内部inlineBox的高度而决定的
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta http-equiv="X-UA-Compatible" content="ie=edge">
            <title>inline</title>
            <style>
                span{
                    background:red;
                }
                .c1{
                    line-height: 20px;
                }
                .c2{
                    line-height: 8px;
                }
                .c3{
                    line-height: 30px;
                }
                .c5{
                    line-height: 28px;
                }
            </style>
        </head>
        <body>
            <div>
                <span class="c1">inline box xfg中文</span>
                <span class="c2">inline box</span>
                <span class="c3">inline box</span>
                inline box
                <span class="c5">inline box</span>
            </div>
        </body>
        </html>
        

        上面的例子中,每个line-height都不一样,但是用浏览器打开之后,发现显示的行高都是一样的。这是由于其外部的形成的lineBox统一决定的,lineBox的行高是由其内部最大的行高决定的。30px

      • 行高相关的现象和方案

        • 不同的字体大小在一行中,是根据baseline来对齐的。
        • 可以使用vertical-align来设置对齐方式
        • 经典问题:文字和图片在一行中,会发现图片出现与下底线之间存在空隙的问题,就是因为图片同文字使用默认的baseline对齐导致的,可以通过设置图片的vertical-align:bottom来解决
    • 背景

      • 背景颜色
      • 渐变色背景
      • 多背景叠加
      <!DOCTYPE html>
      <html>
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <meta http-equiv="X-UA-Compatible" content="ie=edge">
          <title>background</title>
          <style>
              body{
                  background:yellow;
              }
              .c1{
                  height:90px;
                   background:rgba(255,0,0, .3); 
                  /* background:url(./test.png); */
              }
              .c2{
                  height:90px;
                  /* background: -webkit-linear-gradient(left, red, green); */
                  /* background: linear-gradient(to right, red, green); */
                  /* background: linear-gradient(180deg, red, green); */
                  /* background: linear-gradient(135deg, red 0, green 10%, yellow 50%, blue 100%); */
                  background: linear-gradient(135deg, transparent 0, transparent 49.5%, green 49.5%, green 50.5%, transparent 50.5%, transparent 100%),
                      linear-gradient(45deg, transparent 0, transparent 49.5%, red 49.5%, red 50.5%, transparent 50.5%, transparent 100%);
                  background-size: 30px 30px;
              }
          </style>
      </head>
      <body>
          <div class="c1">
      
          </div>
          <div class="c2">
      
          </div>
      </body>
      </html>
      
      • 背景图片和属性(雪碧图(很多需要的图标直接在一张图片中,通过设置位置来实现))
      • base64和性能优化
        • 图片直接使用base64格式,只适用于小图标
      • 多分辨率适配
      <!DOCTYPE html>
      <html>
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <meta http-equiv="X-UA-Compatible" content="ie=edge">
          <title>background</title>
          <style>
              .c1{
                  height:900px;
                  background:red url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHoAAAA2CAYAAAAIw43zAAAMJGlDQ1BJQ0MgUHJvZmlsZQAASImVlwdUU0kXx+eVJCQktEAEpITeBOlVeo1UqYKNkAQSSgiBoGJHFxVYCyoWrMiqiG0tgCwqYlcWwd4XRFCUdbFgQ+WbJICu+5XzzTnz5nfu3Lnzv/PmzXkDgHIUWyTKRFUAyBLmiaOD/ZiTE5OYpE5ABtpADRgAYzYnV+QbFRUGYBlp/17e3QKItL1uLY31z/7/WlS5vFwOAEgU5BRuLicL8lEAcGeOSJwHAKEP2o1m5okgE6FKoC6GAiEbSzlNzq5STpFzmMwnNtofcjIAClQ2W5wGgJJUFzOfkwbjKJVCthVyBULIjZC9OHw2F/JnyOOysrIhK5tDNk/5Lk7a32KmjMZks9NGWZ6LrCgECHJFmezZ/+dy/O+SlSkZmcMIVipfHBItzVm6bhnZoVKmQr4oTImIhKwG+YaAK/OXcg9fEhI37P+Bk+sP1wwwAECpXHZAKGQdyIaSjDjfYfZii2VjoT+aVMCPTZDHR4Xi7Ojh+GiBMDMibDhOKZ/HGuFKXm5gzIhPqiCIBRm+Q7RekMeKHY55MV8QHwFZCfKD3IyY0OGxzwv4/hGjc0mipZrhO8dAVu5ILphxqjgoWu6POfMFrIhhe1gePzZEPhabzmHLNGhCTuflTg4b0cPlBQTK9WCFPGHcsE6sTJTnFz3sXyXKjBr2xxp5mcFSuyHk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2wonpanIUywAZIxlWmWB21zqC0gN12xlDcztu2BQx4M9JrXaJ6byluDe2UHoNM4qMybOCk5B21zrCdHJr3gyCQfbBaTJi+EB/Mr+38Ieje5697JabS2mzEujKhQtTcWpWlR0Pi6Bj5nNmFkkEztfWNoMLnevVVnJqE4RSvanAlfbjWPw2DohSk5g+zWg7guywC5yGmlv8jhpm4uAivIKpDq74f8XRroQjQIVC9Dty4uYNpsxohxBl0Tv9EyJ+vupMMLp2K2IX17ABd3ataMz0MTuDq+6MSPvouBptdK0ZYMtKLx0SfPQNNrpWhLBlrR+OiTZ6DptVK0JQOtaHz0yTPQ9Fop2pKBVjQ++uQZaHqtFG3JQCsaH33yDDS9Voq2ZKAVjY8+eQaaXitFW/4FdhzkzmcYrBcAAAAASUVORK5CYII=);
                  background-repeat: no-repeat;
                  /* background-position: center top; */
                  /* background-position: 20px 30px; */
                  /* background-size:100px 50px; */
              }
              .c2{
                  width:20px;
                  height:20px;
                  background:url(./test_bg.png) no-repeat;
                  background-position: -17px -5px;
                  background-size: 261px 113px;
              }
              .c3{
                  width:20px;
                  height:20px;
                  background:url(./test_bg.png) no-repeat;
                  background-position: -169px -23px;
                  background-size: 261px 113px;
              }
          </style>
      </head>
      <body>
          <div class="c1">
      
          </div>
          <div class="c2">
      
          </div>
          <div class="c3">
      
          </div>
      </body>
      </html>
      
    • 边框

      • 边框:线型 大小 颜色
      • 边框背景图
      <!DOCTYPE html>
      <html>
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <meta http-equiv="X-UA-Compatible" content="ie=edge">
          <title>border</title>
          <style>
              .c1{
                  width:400px;
                  height: 200px;
                  /* border: 1px solid red; */
                  /* border:5px solid red; */
                  /* border:5px dotted red; */
                  border:5px dashed red;
              }
              .c2{
                  width:400px;
                  height: 200px;
                  /* border-width: 30px; */
                  border:30px solid transparent;
                  border-image:url(./border.png) 30 round;
              }
              .c3{
                  width:400px;
                  height: 200px;
                  border-bottom:30px solid red;
                  /* border-right:30px solid blue; */
                  border-left:30px solid transparent;
                  border-right:30px solid transparent;
              }
          </style>
      </head>
      <body>
          <div class="c1">
      
          </div>
          <div class="c2">
      
          </div>
          <div class="c3">
      
          </div>
      </body>
      </html>
      
    • 滚动

      • 滚动行为和滚动条
      <!DOCTYPE html>
      <html>
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <meta http-equiv="X-UA-Compatible" content="ie=edge">
          <title>scroll</title>
          <style>
              .c1{
                  background:red;
                  height:200px;
                  overflow: hidden;
                  overflow: visible;
                  overflow: auto;
                  overflow: scroll;
              }
          </style>
      </head>
      <body>
          <div class="c1">
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
              <p>段落</p>
          </div>
      </body>
      </html>
      
    • 文字折行(灰常复杂)

      • word-wrap通用换行控制
      • word-break针对多字节文字
        • 可以设置句子是一个单位,不换行
      • white-space空白处是否断行
      <!DOCTYPE html>
      <html>
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <meta http-equiv="X-UA-Compatible" content="ie=edge">
          <title>warp</title>
          <style>
              .c1{
                  border: 1px solid;
                  width: 8em;
                  overflow-wrap: normal;
                  word-break: normal;
                  white-space: normal;
              }
      
          </style>
      </head>
      <body>
          <div class="c1">
              This is a long and Supercalifragilisticexpialidocious sentence. 一二三四五六,七八九零一二,这是一句巨长巨长又没有空间可以换行的句子哦。
          </div>
      </body>
      </html>
      
posted @ 2018-12-22 22:53  麦兜爱学习  阅读(2725)  评论(0编辑  收藏  举报