Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
檀越@新空间
Coding Tree
提交
e1aab88f
C
Coding Tree
项目概览
檀越@新空间
/
Coding Tree
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coding Tree
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e1aab88f
编写于
1月 25, 2022
作者:
彭世瑜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
5ea0d913
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
289 addition
and
1 deletion
+289
-1
blog/front-end-learn/css-decorate.md
blog/front-end-learn/css-decorate.md
+79
-1
blog/front-end-learn/css-position.md
blog/front-end-learn/css-position.md
+14
-0
blog/front-end-learn/css-product-2.md
blog/front-end-learn/css-product-2.md
+83
-0
blog/front-end-learn/demo/css-decorate-13.html
blog/front-end-learn/demo/css-decorate-13.html
+32
-0
blog/front-end-learn/demo/css-decorate-14.html
blog/front-end-learn/demo/css-decorate-14.html
+9
-0
blog/front-end-learn/demo/css-decorate-15.html
blog/front-end-learn/demo/css-decorate-15.html
+15
-0
blog/front-end-learn/demo/css-position-1.html
blog/front-end-learn/demo/css-position-1.html
+28
-0
blog/front-end-learn/demo/css-position-2.html
blog/front-end-learn/demo/css-position-2.html
+27
-0
blog/front-end-learn/demo/img/jd-sprite.png
blog/front-end-learn/demo/img/jd-sprite.png
+0
-0
blog/front-end-learn/index.md
blog/front-end-learn/index.md
+2
-0
未找到文件。
blog/front-end-learn/css-decorate.md
浏览文件 @
e1aab88f
...
...
@@ -159,4 +159,82 @@ background-color: rgba(0, 0, 0, 0.5);
[](
demo/css-decorate-12.html
':include height=120'
)
https://www.bilibili.com/video/BV1Kg411T7t9?p=166&spm_id_from=pageDriver
## 精灵图(雪碧图, sprite)
将多张小图合并成一张大图
-
优点:减少服务器发送次数,减轻服务器压力,提高页面加载速度
-
缺点:修改起来比较麻烦
精灵图使用步骤
1.
设置盒子尺寸和小图尺寸相同
2.
将精灵图设置为盒子的背景图片
3.
修改背景图位置
[](
demo/css-decorate-13.html
':include :type=code'
)
[](
demo/css-decorate-13.html
':include height=70'
)
## 背景图片大小 background-size
```
css
background-size
:
宽度
高度
;
```
| 取值 | 场景 |
| ------- | -------------------------------------------------------------------- |
| 数字+px | 简单方便 |
| 百分比 | 相对于当前盒子自身的宽高百分比 |
| contain | 包含,背景图等比缩放,直到不会超出盒子的最大,可能有留白 |
| cover | 覆盖,背景图等比缩放,直到刚好填满整个盒子没有空白,图片可能显示不全 |
background 连写
```
css
background
:
color
image
repeat
position
/
size
;
```
## 盒子阴影 box-shadow
| 参数 | 作用 |
| -------- | -------------------------- |
| h-shadow | 必须,水平偏移量,允许负值 |
| v-shadow | 必须,垂直偏移量,允许负值 |
| blur | 可选,模糊度 |
| spread | 可选,阴影扩大 |
| color | 可选,阴影颜色 |
| inset | 可选,将阴影改为内部阴影 |
[](
demo/css-decorate-14.html
':include :type=code'
)
[](
demo/css-decorate-14.html
':include height=120'
)
## 过渡 transition
-
让元素样式慢慢变化
-
常配合 hover 使用
```
css
transition
属性
时长
,
属性
时长
;
```
| 参数 | 取值 |
| -------- | ---------------------------- |
| 过渡属性 | 所有属性 all;具体属性 width |
| 过渡时长 | 数字 + s(秒) |
注意:
-
过渡需要默认状态和 hover 样式不同,才能有过渡效果
-
transition 属性给需要过渡的元素本身加
-
transition 属性设置在不同状态中,效果不同
-
给默认状态设置,鼠标移入移出都有过渡效果
-
给 hover 状态设置,鼠标移入有过渡效果,移出没有过渡效果
[](
demo/css-decorate-15.html
':include :type=code'
)
[](
demo/css-decorate-15.html
':include height=120'
)
blog/front-end-learn/css-position.md
浏览文件 @
e1aab88f
...
...
@@ -100,3 +100,17 @@ positions: fixed;
/* 默认值0;数值越大,显示越靠前 */
z-index
:
数值
;
```
## 案例:子盒子在父盒子中水平居中
方式一:margin
[](
demo/css-position-1.html
':include :type=code'
)
[](
demo/css-position-1.html
':include height=520'
)
方式二:transform
[](
demo/css-position-2.html
':include :type=code'
)
[](
demo/css-position-2.html
':include height=520'
)
blog/front-end-learn/css-product-2.md
0 → 100644
浏览文件 @
e1aab88f
# CSS 实战 2
## 网站骨架结构标签
```
html
<!-- 文档类型声明,HTML5 -->
<!DOCTYPE html>
<!-- 网页语言,中文zh-CN -->
<html
lang=
"en"
>
<!-- 网页字符编码 -->
<meta
charset=
"UTF-8"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
/>
<!-- 移动端使用 -->
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
</html>
```
## SEO
Search Engine Optimization 搜索引擎优化
提升网站排名方法:
1.
竞价排名
2.
将网页制作成 html 后缀
3.
标签语义化,适合的地方使用合适的标签
## SEO 三大标签
1.
title 标题
2.
description 描述
3.
keywords 关键词,英文逗号分隔
```
html
<title>
Coding Tree
</title>
<meta
name=
"description"
content=
"Description"
/>
<meta
name=
"keywords"
content=
"keywords1,keywords2"
/>
```
## icon 图标
favicon.ico 文件放根路径
```
html
<link
rel=
"shortcut icon"
href=
"favicon.ico"
type=
"image/x-icon"
/>
```
## 项目结构搭建
文件和目录准备
```
favicon.ico
index.html 首页
css/
base.css 基本公共的样式 清除浏览器默认样式
common.css 重复使用样式 网页头,网页尾
index.css 页面单独的样式
images/ 固定使用的图片素材
uploads/ 非固定使用的图片素材
```
https://www.bilibili.com/video/BV1Kg411T7t9?p=177&spm_id_from=pageDriver
blog/front-end-learn/demo/css-decorate-13.html
0 → 100644
浏览文件 @
e1aab88f
<style>
.box
{
background-image
:
url('./img/jd-sprite.png')
;
background-repeat
:
no-repeat
;
background-size
:
113px
86.5px
;
width
:
36px
;
height
:
42px
;
display
:
inline-block
;
margin-right
:
50px
;
}
.box-1
{
background-position
:
0
0
;
}
.box-2
{
background-position
:
-38.5px
0
;
}
.box-3
{
background-position
:
-77px
0
;
}
.box-4
{
background-position
:
0
-44.5px
;
}
</style>
<div
class=
"box box-1"
></div>
<div
class=
"box box-2"
></div>
<div
class=
"box box-3"
></div>
<div
class=
"box box-4"
></div>
\ No newline at end of file
blog/front-end-learn/demo/css-decorate-14.html
0 → 100644
浏览文件 @
e1aab88f
<style>
.box
{
width
:
100px
;
height
:
100px
;
box-shadow
:
0
10px
50px
8px
#ccc
;
}
</style>
<div
class=
"box"
></div>
\ No newline at end of file
blog/front-end-learn/demo/css-decorate-15.html
0 → 100644
浏览文件 @
e1aab88f
<style>
.box
{
width
:
100px
;
height
:
100px
;
background-color
:
skyblue
;
transition
:
all
2s
;
}
.box
:hover
{
width
:
200px
;
background-color
:
pink
;
}
</style>
<div
class=
"box"
></div>
\ No newline at end of file
blog/front-end-learn/demo/css-position-1.html
0 → 100644
浏览文件 @
e1aab88f
<style>
.box-wrap
{
position
:
relative
;
width
:
500px
;
height
:
500px
;
background-color
:
skyblue
;
}
.box
{
position
:
absolute
;
left
:
50%
;
top
:
50%
;
/* 手动计算盒子的一半 */
margin-left
:
-150px
;
margin-top
:
-150px
;
width
:
300px
;
height
:
300px
;
background-color
:
pink
;
}
</style>
<div
class=
"box-wrap"
>
<div
class=
"box"
></div>
</div>
\ No newline at end of file
blog/front-end-learn/demo/css-position-2.html
0 → 100644
浏览文件 @
e1aab88f
<style>
.box-wrap
{
position
:
relative
;
width
:
500px
;
height
:
500px
;
background-color
:
skyblue
;
}
.box
{
position
:
absolute
;
left
:
50%
;
top
:
50%
;
/* 移动自身一半 */
transform
:
translate
(
-50%
,
-50%
);
width
:
300px
;
height
:
300px
;
background-color
:
pink
;
}
</style>
<div
class=
"box-wrap"
>
<div
class=
"box"
></div>
</div>
\ No newline at end of file
blog/front-end-learn/demo/img/jd-sprite.png
0 → 100644
浏览文件 @
e1aab88f
9.1 KB
blog/front-end-learn/index.md
浏览文件 @
e1aab88f
...
...
@@ -37,3 +37,5 @@
11.
[
CSS 定位
](
blog/front-end-learn/css-position.md
)
12.
[
CSS 装饰
](
blog/front-end-learn/css-decorate.md
)
13.
[
CSS 实战 2
](
blog/front-end-learn/css-product-2.md
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录