Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
檀越@新空间
Coding Tree
提交
7fa585ee
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看板
提交
7fa585ee
编写于
2月 17, 2022
作者:
彭世瑜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
b8451cc0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
196 addition
and
3 deletion
+196
-3
blog/front-end-combat/demo/flex-1.html
blog/front-end-combat/demo/flex-1.html
+82
-0
blog/front-end-combat/flex.md
blog/front-end-combat/flex.md
+70
-0
blog/front-end-combat/img/flex.png
blog/front-end-combat/img/flex.png
+0
-0
blog/front-end-combat/index.md
blog/front-end-combat/index.md
+4
-3
blog/front-end-combat/mobile.md
blog/front-end-combat/mobile.md
+40
-0
未找到文件。
blog/front-end-combat/demo/flex-1.html
0 → 100644
浏览文件 @
7fa585ee
<style>
h3
{
text-align
:
center
;
}
.box-wrap
{
display
:
flex
;
margin
:
0
auto
;
width
:
500px
;
border
:
1px
solid
#eee
;
}
.box-wrap
+
.box-wrap
{
margin-top
:
20px
;
}
.box
{
width
:
100px
;
height
:
100px
;
font-size
:
20px
;
line-height
:
100px
;
text-align
:
center
;
background-color
:
skyblue
;
}
/* 居中 */
.box-center
{
justify-content
:
center
;
}
/* 间距在盒子之间 */
.box-between
{
justify-content
:
space-between
;
}
/* 间距在子两侧,视觉效果:子级之间的距离是两头距离的 2 倍 */
.box-around
{
justify-content
:
space-around
;
}
/* 盒子和容器所有间距相等 */
.box-evenly
{
justify-content
:
space-evenly
;
}
</style>
<h3>
默认
</h3>
<div
class=
"box-wrap"
>
<div
class=
"box"
>
1
</div>
<div
class=
"box"
>
2
</div>
<div
class=
"box"
>
3
</div>
</div>
<h3>
justify-content: center;
</h3>
<div
class=
"box-wrap box-center"
>
<div
class=
"box"
>
1
</div>
<div
class=
"box"
>
2
</div>
<div
class=
"box"
>
3
</div>
</div>
<h3>
justify-content: space-between;
</h3>
<div
class=
"box-wrap box-between"
>
<div
class=
"box"
>
1
</div>
<div
class=
"box"
>
2
</div>
<div
class=
"box"
>
3
</div>
</div>
<h3>
justify-content: space-around;
</h3>
<div
class=
"box-wrap box-around"
>
<div
class=
"box"
>
1
</div>
<div
class=
"box"
>
2
</div>
<div
class=
"box"
>
3
</div>
</div>
<h3>
justify-content: space-evenly;
</h3>
<div
class=
"box-wrap box-evenly"
>
<div
class=
"box"
>
1
</div>
<div
class=
"box"
>
2
</div>
<div
class=
"box"
>
3
</div>
</div>
\ No newline at end of file
blog/front-end-combat/flex.md
0 → 100644
浏览文件 @
7fa585ee
# Flex 布局
## 百分比布局
百分比布局也叫流式布局
效果:宽度自适应,高度固定
```
css
width
:
100
%;
height
:
50
px
;
```
## Flex 布局
Flex 布局: 弹性布局
-
浏览器提倡的布局模型
-
布局网页更简单,灵活
-
避免浮动脱标的问题
-
非常适合结构化布局
Float 浮动布局
-
最初为了实现文字环绕
-
Float 布局会造成浮动的盒子脱标,不能撑开父级容器
Flex 布局示例
```
css
.box
{
display
:
flex
;
}
```

查看 web 技术浏览器兼容性:
https://caniuse.com/
Flex 布局组成部分
-
弹性容器: 直接父级
-
弹性盒子:直接子级
-
主轴:默认 x 轴
-
侧轴/交叉轴:默认 y 轴
flex 容器下的元素默认水平排列:默认主轴在 x 轴,弹性盒子沿着主轴排列
## 主轴对齐方式 justify-content
Flex 布局模型中,可以调节主轴或侧轴的对齐方式来设置盒子之间的间距
| 属性值 | 作用 |
| ------------- | ---------------------------------------------------- |
| flex-start | 默认值,起点开始依次排列 |
| flex-end | 终点开始依次排列 |
| center | 沿主轴居中排列 |
| space-around | 弹性盒子沿主轴均匀排列,空白间距均分在弹性[盒子两侧] |
| space-between | 弹性盒子沿主轴均匀排列,空白间距均分在相邻[盒子之间] |
| space-evenly | 弹性盒子沿主轴均匀排列,弹性盒子与容器之间[间距相等] |
示例:
[](
demo/flex-1.html
':include :type=code'
)
[](
demo/flex-1.html
':include height=900'
)
https://www.bilibili.com/video/BV1xq4y1q7jZ?p=67&spm_id_from=pageDriver
blog/front-end-combat/img/flex.png
0 → 100644
浏览文件 @
7fa585ee
259.1 KB
blog/front-end-combat/index.md
浏览文件 @
7fa585ee
...
@@ -10,7 +10,8 @@
...
@@ -10,7 +10,8 @@
4.
[
动画 animation
](
blog/front-end-combat/animation.md
)
4.
[
动画 animation
](
blog/front-end-combat/animation.md
)
-
css3 平面、渐变、动画属性
5.
[
移动端网页适配
](
blog/front-end-combat/mobile.md
)
-
Flex 布局
-
移动适配
6.
[
Flex 布局
](
blog/front-end-combat/flex.md
)
-
响应式 BootStrap 框架
-
响应式 BootStrap 框架
blog/front-end-combat/mobile.md
0 → 100644
浏览文件 @
7fa585ee
# 移动端网页适配
## 屏幕尺寸
屏幕对角线的长度,一般用英寸来度量
## PC 分辨率
```
1920 * 1080
1366 * 768
```
-
硬件分辨率 物理分辨率 不可改变,固定的
-
软件分辨率 逻辑分辨率 由软件驱动决定
移动端主流设备分辨率
| 手机型号 | 物理分辨率 | 逻辑分辨率 | 比例关系 |
| ----------- | ----------- | ---------- | -------- |
| iPhone6/7/8 | 750
\*
1334 | 375
\*
667 | 2:1 |
## 视口
-
移动端网页宽度默认:
`980px`
-
PC 端网页宽度和屏幕宽度相同
视口的作用:
```
网页宽度 = 逻辑宽度
```
视口标签
```
html
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
```
二倍图:750px
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录