学Web的第二十一天

1、calc()函数

  • 用于动态计算长度值,值灵活

  • css3新增功能

  • 任何长度值都可以使用calc()函数进行计算;

  • calc()函数支持 "+", "-", "*", "/" 运算;

  • calc()函数使用标准的数学运算优先级规则;

  • 运算符前后都需要保留一个空格

  • 语法: calc(表达式)

运算符前后都需要保留一个空格
width: calc(100% - 200px);  减号的前后添加空格
​
.box {
    width: calc(100% - (10px + 20px) * 2);
    height: 300px;
    background-color: pink;
}
  • 浏览器支持 在IE9+、Firefox、chrome、safari可以正常呈现

  • 利用calc()实现三栏自适应布局

    <!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>
            * {
                margin: 0;
                padding: 0;
            }
    ​
            .box {
                height: 500px;
                background-color: pink;
            }
    ​
            .box p {
                float: left;
            }
    ​
            /* 左右两栏 */
            .box p:nth-child(1),
            .box p:nth-child(3) {
                width: 200px;
                height: 480px;
                background-color: red;
            }
    ​
            /* 中间 */
            .box p:nth-child(2) {
                height: 480px;
                background-color: green;
                /* calc运算 */
                width: calc(100% - 400px);
            }
        </style>
    </head>
    ​
    <body>
        <div class="box">
            <p>左边</p>
            <p>中间</p>
            <p>右边</p>
        </div>
    </body>
    ​
    </html>

2、css3过渡动画——transition属性

  • 语法

transition: transition-proterty transition-duration transition-timing-function transition-delay;
transition: css样式  动画的执行时间  速度类型  动画的延迟时间;
 多个css属性用逗号隔开
 transition: transform 2s, background-color 2s;
​
注意:谁发生了属性的改变 就加在谁身上
  • 属性

    1、transition-proterty

    • css样式:参与过渡的css属性名称|all表示所有属性

    2、transition-duration

    • 动画执行时间:默认0s,s|ms(毫秒) 1s=1000ms

    3、transition-timing-function

    • 速度类型

      1.linear 相同的速度从开始到结束,也就是匀速 2.ease 默认值 慢速度开始--速度变快--慢速度结束 3.ease-in 慢速度开始的过渡效果,也就是以低速度开始 4.ease-out 慢速度结束的过渡效果,也就是以低速结束 5.ease-in-out 以慢速度开始和结束的过渡效果

    4、transition-delay

    • 延迟时间:默认0s,单位s|ms

注意:必须设置transition-duration属性,否则执行时间为0,不会产生过渡效果

<!DOCTYPE html>
<html lang="e
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值