e 11 months ago
parent
commit
1fee12ab7d
3 changed files with 95 additions and 0 deletions
  1. 5 0
      css/1.css
  2. 33 0
      css/1.引入样式.html
  3. 57 0
      css/2.常用样式.html

+ 5 - 0
css/1.css

@@ -0,0 +1,5 @@
+div {
+    width: 200px;
+    height: 200px;
+    background: #ff0;
+}

+ 33 - 0
css/1.引入样式.html

@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <!-- 
+        link 用于引入外部文件
+        rel 关系
+        stylesheet 样式表
+        href
+     -->
+     <!-- 3.外部样式表 -->
+    <link rel="stylesheet" href="./1.css">
+    <!-- 2.内部样式表 -->
+    <style>
+        div {
+            width: 200px;
+            height: 200px;
+            background: #00f;
+        }
+    </style>
+</head>
+<body>
+    <!-- 
+        优先级:
+        行内 > 内部 > 外部
+     -->
+    <!-- 1.行内样式/内联样式 -->
+    <!-- <div style="width: 200px;height: 200px;background: #f00;"></div> -->
+    <div></div>
+</body>
+</html>

+ 57 - 0
css/2.常用样式.html

@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <style>
+        /* 1.标签选择器 
+            标签名称 {样式}
+        */
+        #box1 {
+            /* 宽度 */
+            /* 像素单位 px */
+            width: 800px;
+            /* 高度 */
+            height: 800px;
+            /* 背景 复合属性
+               background: color repeat position image;
+            */
+            /* background: red; */
+            /* 
+                背景色:background-color
+                背景图:background-image:url("路径")
+                背景平铺:background-repeat
+                    repeat 平铺 no-repeat 不平铺 repeat-x 横轴平铺 repeat-y 纵轴平铺
+                背景尺寸:background-size
+                    contain 等比例放到最大 cover 全覆盖
+                背景位置:background-position 
+                    top left center right bottom 直接给距离也可以
+            */
+            /* background-color: rgb(227, 227, 30); */
+            /* background-image: url("../html/images/img01.gif"); */
+            /* background-repeat: no-repeat; */
+            /* background-size:contain; */
+            /* background-position: 10%; */
+            background: red no-repeat center url("../html/images/img01.gif");
+        }
+        #box2 {
+            width: 300px;
+            height: 300px;
+            background: blue;
+        }
+        /* 写样式的时候 相同标签相同样式 后面的会覆盖前面的 */
+        /* id选择器
+            在body标签内
+                在开始标签中添加 id='名字'
+            在style中
+                #名字 {样式...}
+        */
+    </style>
+    
+</head>
+<body>
+    <div id="box1"></div>
+    <div id="box2"></div>
+</body>
+</html>