Web前端第四章(清华 2019.2.23)

本文深入探讨了响应式布局的三大关键技术:流式布局、弹性媒体和媒体查询。讲解了vw/vh单位、max-width应用、媒体查询语法及新旧版本区别,包括宽度变化、宽高比调整和移动优先策略。此外,还介绍了CSS变换如rotate、scale、translate和skew,以及transform-origin的使用。最后,覆盖了transition和animation效果,包括关键帧定义和动画属性设置。

响应式布局
三大关键技术:流式布局,弹性媒体,媒体查询

Vw vh
100vw=100%(和适口相同)
Max-width 大屏保持 小屏变化

Media query 媒体查询
宽度变化:
@media(width<=600px){
nav,section{float:none;width:auto;}
Height:100px;
} //新版本
@media(max-width=600px){
nav,section{float:none;width:auto;}
Height:100px;
} //老版本

@media screen/all and (max-width=600px){
nav,section{float:none;width:auto;}
Height:100px;
}

@media mt and (mf1) and (mf2) and (mf3){
Rule1
Rule2
}

宽高比
@media(aspect-ratio>=16:9){
}
@media(min-aspect-ratio:16/9){
} //老版本

IE6以下 respond.js 开源语法

移动优先响应式布局 mobile first
优点:需求优先,加速渲染,节约网络资源带宽
Css rules for mobile device…
@media screen and (wdith>=768px){
R1
R2
}

@media screen and (min-wdith:768px){
R1
R2
} //老版本

Transform 变换
对行内元素不起作用 display->…
Transform:rotate(50deg) 顺时针旋转
Transform:scale(2) 放大两倍
Transform:scalex/scaley(2) 垂直水平方向缩放
Transform:scale(.5,2) 水平,垂直
Transform:translate(20px,40px)
Transform:translateX(20px) 向右平移20px
Transform:skew(45deg) 左倾斜45度 X轴

Transform: translate(20px) scale(2) rotate(45deg); //组合 从右往左
Transform: 矩阵…
Transform-origin (基点)
transform-origin:left top;
Transform-origin:right bottom; / 100% 100%; / 20px 30px;

兼容性:www.camiuse.com MDN

便准写法:带上厂商前缀(兼容性)
-webkit-transform:scale(.5); //safari
-moz-transform:scale(.5); //firefox
-ms-transform:scale(.5); //IE
-o-transform:scale(.5); //opera
Transform:(.5);

Transition 过度变化效果 —animated可动画属性
Transition-property:width,background-color;
Transition-duration:3s,1s;

4个基本属性:
Transition-property:none/all(默认)
Transition-duration:6s/1s,2s/40ms/0(默认)
Transition-delay: 2s 执行前的等待时间
Transition-timing-function:linear/ ease/ease-in/ease-out/ease-in-out 过渡时间函数
简写属性:
Transition:width 4s linear 1s,height 1s linear 0s(delay);

Animation 动画
@keyframes 关键帧
@keyframes bounce{
0%{
Left:0;
Top:0;
}
50%{
Left:200px;
Top:200px;
}
100%{
Left:400px;
Top:0px;
}
}
Animation:bounce 4s linear 0s; //引入bonce动画

.box:hover.ball{
Animation:bounce 4s linear 0s;
} //鼠标接触开始动画
Animation-name:bounce;
Animation-duration:4s;
Animation-timing-function:linear;
Animation-delay:0s;

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Nature68c

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值