侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

前端第61天过渡动画、盒子阴影、伪类设计边框

2023-01-12 星期四 / 0 评论 / 0 点赞 / 69 阅读 / 8722 字

一.拼接网页 将区域整体划分起名 => 对其他区域布局不产生影响提出公共css => reset操作当有区域发送显示重叠(脱离文档流导致的),需要通过z-index调整层级一定需要最外层,且最外层做自

... .

一.拼接网页

将区域整体划分起名 => 对其他区域布局不产生影响
提出公共css => reset操作
当有区域发送显示重叠(脱离文档流导致的),需要通过z-index调整层级
一定需要最外层,且最外层做自身布局时,不要做过多布局操作

二、过渡

transition属性

transition: 过渡时间(必须) 延迟时间(一般不设) 过渡属性(一般采用all默认值) 过渡曲线(贝赛尔曲线)(cubic-bezier())

过渡属性具体设置给初始状态还是第二状态 根据具体需求
```

```css
/*过渡的持续时间*/
transition-duration: 2s;
/*延迟时间*/
transition-delay: 50ms;
/*过渡属性*/
/*单一属性 | 属性1,...,属性n | all*/
transition-property: all;
/*过渡曲线*/
/*cubic-bezier() | ease | ease-in | ease-out | ease-in-out | linear*/
transition-timing-function: cubic-bezier(0,2.23,0.99,-1.34);
```

```css
/*结论:*/
/*1.尽量悬浮静止的盒子,控制运动的盒子*/
/*2.不能确定区间范围的属性值,不会产生动画效果*/
/*display 不能做动画 | opacity 可以做动画*/

.
<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <title>动画</title>    <style type="text/css">        .box {            width: 200px;            height: 200px;            background-color: red;            /*通过过渡完成动画*/            /*transition: 1s;*/                        /*过渡的持续时间*/            transition-duration: 2s;            /*延迟时间*/            transition-delay: 50ms;            /*过渡属性*/            /*单一属性 | 属性1,属性n | all*/            transition-property: all;            /*过渡曲线*/            /*cubic-bezier() | ease | ease-in | ease-out | ease-in-out | linear*/            transition-timing-function: cubic-bezier(0,-1.34);        }        .box:hover {            width: 800px;            height: 400px;            background-color: orange;        }    </style>    <style type="text/css">        .sup {            width: 800px;            height: 50px;            background-color: pink;            margin: 0 auto;        }        .sub {            width: 50px;            height: 50px;            background-color: orange;            /*整体设置: 注意点 第一个时间为过渡时间,第二个为延迟时间,可以省略,运动曲线和运动属性可以省略,位置也不做要求*/            /*transition: .1s 1s all ease;*/            transition: .7s ease-in-out;            /*display: none;*/            /*opacity: 0;*/        }        .sup:hover .sub {            /*margin-left: auto;*/            /*display: block;*/            /*opacity: 1;*/            margin-left: calc(100% - 50px);        }        /*结论:*/        /*1.尽量悬浮静止的盒子,控制运动的盒子*/        /*2.不能确定区间范围的属性值,不会产生动画效果*/        /*display 不能做动画  | opacity可以做动画*/    </style></head><body>    <!-- 案例 -->    <div class="sup">        <div class="sub"></div>    </div>    <!-- 动画: 从一种状态渐变(非瞬变)到另一种状态 -->    <!-- HTML5如何实现动画: transition(过渡) | animation(动画) -->    <div class="box"></div>    
.

三、阴影


```css
/*x轴偏移量 y轴偏移量 虚化程度 阴影宽度 阴影颜色*/
box-shadow: 0 0 10px 10px black;

/*一个盒子可以设置多个阴影,每一套阴影间用逗号隔开*/
box-shadow: 0 -10px 10px -5px black,0 10px 10px -5px black;
```

.
!DOCTYPE html><html><head>    <meta charset="UTF-8">    <title>盒子阴影</title>    <style type="text/css">        body {            margin: 0;        }        .box {            width: 200px;            height: 200px;            background-color: cyan;            /*屏幕正中央*/            margin-top: calc(50vh - 100px);            margin-left: calc(50vw - 100px)        }        .box {            /*x轴偏移量 y轴偏移量 虚化程度 阴影宽度 阴影颜色*/            /*box-shadow: 0 0 10px 10px black;*/            /*一个盒子可以设置多个阴影*/            box-shadow: -250px 0 10px 0 red,250px -50px 0 10px blue,100px -225px 10px 10px yellow,0 10px 10px -5px #333;        }    </style></head><body>    <div class="box"></div></body></html>
.

 

 四.伪类实现边框

```css
/*自身需要定位*/
.box {
position: relative;
}
/*伪类通过定位来完成图层的布局*/
.box:before {
content: "";
/*完成布局*/
position: absolute;
top: 10px;
left: 0;
/*构建图层*/
width: 1px;
height: 100px;
background-color: black;
}
.box:after {
content: "";
position: absolute;
width: 100px;
height: 1px;
background-color: black;
top: 0;
left: 10px;
}
```

.
<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <title>伪类设计边框</title>    <style type="text/css">        .box {            width: 200px;            height: 200px;            background-color: yellow;            margin: 50px auto;            position: relative;        }                /*:before | :after*/        .box:before {            content: "";            /*display: block;*/            /*会拉动盒子*/            /*margin-top: 100px;*/            /*正常*/            /*margin-left: 10px;*/            position: absolute;            width: 180px;            height: 1px;            background-color: black;            left: 10px;            top: 199px;        }        .box:after {            content: "";            position: absolute;            width: 1px;            height: 180px;            background-color: black;            top: 10px;            left: 199px;        }    </style></head><body>
. . .. ...

广告 广告

评论区