HTML5基础加强css样式篇(css过度效果)(十八)
来源:互联网 发布:零基础学c语言书籍 编辑:程序博客网 时间:2024/06/10 21:52
1.css过度效果简介:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box { width: 100px; height: 100px; background-color: #7e64ff; /*visibility: hidden;*/ } /*鼠标悬浮在.box时,宽度放大2倍*/ .box:hover{ /*设置有过渡效果的CSS属性*//* 对CSS属性的要求:具有“中间值”得CSS样式 中间值: CSS样式是数值或者可以转化成数值*/ /*transition-property: width;*/ /*transition-property: opacity;*/ /*transition-property: display;*/ /*transition-property: visibility;*/ transition-property: background-color; /*#f00 = red*/ background-color: red; /*opacity: 1;*/ /*display: block;*/ /*设置过渡持续的时间*/ transition-duration: 3s; /*width: 200px;*/ /*opacity: 0;*/ /*display: none;*/ /*visibility: hidden;*/ } </style></head><body><div class="box"></div><script type="text/javascript"></script></body></html>2.css过度效果简单应用:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box { width: 100px; height: 100px; background-color: #7e64ff; border: 1px solid green; } /*需求:鼠标悬浮在.box时,宽度放大2倍,背景色变成红色,高度放大2倍*/ .box:hover{ /*通过,分割多个样式*/ /* 我们不需要特别设置 transition-property: 浏览器默认为我们增加了 transition-property: all */ /*transition-property: width, background-color, height, border;*/ /*transition-property: all;*/ /*仅让宽度产生过渡动画效果*/ transition-property: width; /*当特指某个CSS样式具有过渡动画效果,需要显示设置 transition-property*/ transition-duration: 3s; width: 200px; height: 200px; background-color: #f00; border: 19px solid green; } </style></head><body><div class="box"></div><script type="text/javascript"></script></body></html>
3.过度时间设置transition-duration
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>过度时间设置</title> <style type="text/css"> .box { width: 100px; height: 100px; background-color: #7e64ff; border: 1px solid green; } .box:hover{ /*仅让宽度产生过渡动画效果,过渡时间3ms, 高度4s, 背景色过渡*/ transition-property: width, height, background-color, border; /*transition-duration: 3s;*/ /*transition-duration: 300ms;*/ transition-duration: 2s, 4s, 10s; /* 过渡时间值 ms 毫秒 s 秒 */ width: 200px; height: 200px; background-color: #f00; border: 19px solid green; } </style></head><body><div class="box"></div><script type="text/javascript"></script></body></html>4.过度延时时间:transition-delay
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box, .box1 { width: 100px; height: 100px; background-color: #7e64ff; border: 1px solid green; } body:hover .box{ /*transition-property: width, height, background-color, border;;*/ transition-property: width; transition-duration: 2s; /*过渡延迟执行*/ /*transition-delay: 1s, .1s;*/ /*可以设置负值*/ transition-delay: -1s; width: 200px; /*height: 200px;*/ /*background-color: #f00;*/ /*border: 19px solid green;*/ } body:hover .box1{ transition-property: width; transition-duration: 2s; width: 200px; } </style></head><body><div class="box"></div><div class="box1"></div><script type="text/javascript"></script></body></html>
css过度效果:动态边框应用:
效果图:
代码如下:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box { width: 400px; height: 150px; background-color: forestgreen; position: relative; } .border-box{ background-color: orange; position: absolute; } .border-box-top{ height: 8px; width: 0; } .border-box-right{ width: 8px; height: 0; right: 0; } .border-box-bottom{ height: 8px; width: 0; bottom: 0; right: 0; } .border-box-left{ width: 8px; height: 0; left: 0; bottom: 0; } /* 触发时机:鼠标悬浮在 .box 过渡时间:每个边的过渡时间是1s CSS值变化: 0 到指定的大小 */ .box:hover .border-box-top{ width: 100%; transition-duration: 1s; } .box:hover .border-box-right{ height: 100%; transition-duration: 1s; transition-delay: 1s; } .box:hover .border-box-bottom{ width: 100%; transition-duration: 1s; transition-delay: 2s; } .box:hover .border-box-left{ height: 100%; transition-duration: 1s; transition-delay: 3s; } </style></head><body><div class="box"> <div class="border-box border-box-top"></div> <div class="border-box border-box-right"></div> <div class="border-box border-box-bottom"></div> <div class="border-box border-box-left"></div></div><script type="text/javascript"></script></body></html>
0 0
- HTML5基础加强css样式篇(css过度效果)(十八)
- HTML5基础加强css样式篇(css过度效果:界面的浮层遮罩和消失)(十九)
- HTML5基础加强css样式篇(css过度覆盖问题)(二十一)
- HTML5基础加强css样式篇(css过渡属性简写,cubic-bezier过度曲线函数使用)(二十)
- HTML5基础加强css样式篇(css属性border详解(一))(三十三)
- HTML5基础加强css样式篇(css计算函数:calc())(四十七)
- HTML5基础加强css样式篇(css过渡结束事件:transitionend)(二十三)
- HTML5基础加强css样式篇(css属性border圆角:border-radius)(三十五)
- HTML5基础加强css样式篇(css属性:怪异盒模型解析)(四十六)
- HTML5基础加强css样式篇(文字阴影css属性:text-shadow)(四十四)
- HTML5基础加强css样式篇(color,direction)(二)
- HTML5基础加强css样式篇(line-height)(三)
- HTML5基础加强css样式篇 (高仿百度新闻热门文章窗口)(六)
- HTML5基础加强css样式篇(target目标伪类选择器)(九)
- HTML5基础加强css样式篇(target目标伪类选择器应用)(十)
- HTML5基础加强css样式篇(结构化伪类选择器:nth-of-type)(十一)
- HTML5基础加强css样式篇(属性选择器)(十四)
- HTML5基础加强css样式篇(常用伪元素选择器after,before)(十五)
- zookeeper实战与源码分析----zookeeper安装
- lk_init_struct结构
- mysql启动不了,报错“[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it”
- iOS 获取IP
- 提高Android studio编译(build)速度
- HTML5基础加强css样式篇(css过度效果)(十八)
- RabbitMQ-环境安装
- 企业推广H5这样做,老板对你赞不绝口!
- IOS 获取IOS屏幕尺寸大小以及 获取当前app的名称和版本号
- 信息与信息化
- 使用springBoot实现 web后端(一)
- Android:学习AIDL,这一篇文章就够了(上)
- Java内存模型理解
- Spring Aware (Spring 感知)