像360deg过渡效果,做专题的同学应该是经常做的.
 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>360deg过渡效果</title>
<style type="text/css">
div{
cursor:pointer;
width:100px;
height:40px;
background:#92B901;
font-size:14px;
opacity:0.5;
transition-property:width,height,background,font-size,opacity,transform;
transition-duration:1s,1s,1s,1s,1s,1s;
border-radius:5px;
font-weight:bold;
color:#FFF;
padding:10px;
}
div:hover{
width:120px;
height:60px;
background:#1ec7e6;
font-size:20px;
opacity:1;
transform:rotate(360deg);
}
</style>
</head>
<body>
<div>CSS3 transition</div>
</body>
</html>
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAALYAAABhCAIAAAD0qczEAAAE+klEQVR4nO2dTU7bQBxHOQkLVpWqSvQK5SSRkLhNF0jZ9RBF3eUCodAFCxZmXRIgJZEgEYhIKF0ktsfz9Tf+Gid+P71VNJ5YnpeZsT0DeytCvNkLfQKk7UERIgRFiBAUIUJQhAhBESJEUOTi+a0XTQ8v7/eHYwjO4eV9L5oOn96akWMdnyI/xouD8/DXBTQOzsent/Pwivx6fP36h86jpXy+uDt7fAmsyMnNLPiFAA8nN7PAihxdTYJfBfBwdDUJrEjwSwAiKAICKAICKAICKAICKAICKAICKAICKAICKAIC26NI9PqQPfZ6ZC05Gyyz5RZza4XHs/dsuWXfVqy/kKvabUq2fc6UVMRo9STL12OvRkm5fr4Ks9rZimnf2AGkxq0mpRTJ/I7NpL9st0mZYmb/oUaRabSpbu1NctTDrFtvp71Xv7KUUGSUNrv6E1e8eR9E4/2h2oUozZx+GBdTTFIqTD9MDIi/Iq4tqapjw0355s+T4ookKpgzj/4i2+3HTaj9yo0aYhu0ISNx0WUAitSZworMr9flcs0A4sLSWJD2QB+ZWHhk3W1qckJLaUXy/XBtkwzbfYptVutreKV81/xovSIf79tdc1u9aUeOma31i9TC3NHUk+YU8Rhg6wDSsSmNOBfpmCVVCCCn9EDjeK6Vh7Rf8XuWWuX8rmQg69RwU5MTWmq7o1GaMy6Z3NwmZOe8sQrmlNZdA4rUnuqfi6gzU+3RltYN6Pcvrrln+kVrRSw3U6JDO0m5ps+bZp6u2iYWSoxnYo7ETiTFNgcyF6kztb2j0eYNrvuUlTYR8cikVmgt1q0uZFsUGe8PS7zpdTSq+RDF+sAt0+V0rP/YNkUgECgCAigCAigCAigCAigCAigCAigCAigCAigCAluiyGjZnq0Jjve9s8HSssGiPae9y4qsm6Q919qiyOb9EYoUTwXrRVp8rZMXh8WXxrWZJgRBka2mCUEKK2Ku/XmYzdT1YP3khX68HEQ/xLpMZPl6nFkLojetXkl2DUBmoLHst1j2h06ztRUI2noGtWb1HMKug3S1XbWpRxEl16Oxc+VR2sDulURpGbGSwoo4alYkdi+HC7mOyXVO1abagcax6y67S1tpkuT6KopsGib5xNgYHLecudvbmK7aBhrjtN31pJ2EosimKn1xJIp8UBFh7Dfa0nKgvqg9x1aJQopYd57qH1qW+7dgI3GB9i6QehTxLBPMLGI1FFEONPY9uEaxcoo4piZaVe7baRSpSBHHWP4hRVx/xyZtNhSpI00oYu6scQ40fkWGWsPH0YcDFKkyDShiaadyioz1r9OnkPXNRVBESQ2KxNdX312XSxHLX6sydlgVu6Mx703cdzQookQ+xezMQHt05hpotOhTUV8v4trW5ZmLaHOg8s9FUERJrrNUb08Wc890NWOJWlJ7CiINNP6/t2l706s2//sgcr83sN9qoQjrRbYZFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAEBFAGBwIp8u5oEvwTg4ehqEliRXjQNfhXAQy+aBlbk7PHly+V98AsBVj79vvv57yWwIqvV6vS2W/9ffYv4/ve5GT8ERVar1fDprRdND+lO2sHh5X0vmg6f3pqRYx1BEUJQhAhBESIERYgQFCFCUIQIQREiBEWIEBQhQlCECPkPsT5qeaUIMFsAAAAASUVORK5CYII=" alt="" />
其实触发过渡效果有很多种方式,今天总结一下:
1.最常见的hover触发过渡效果
 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>hover过渡效果</title>
<style type="text/css">
div{cursor:pointer;width:100px;height:40px;background:#92b901;transition:width 0.5s;}
div:hover{width:200px;}
</style>
</head>
<body>
<div></div>
</body>
</html>

2.js添加操作来触发

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js添加样式来触发过渡效果</title>
<style type="text/css">
div{width:100px;height:40px;background:#92b901;transition:width 0.5s;}
.change{width:200px;}
</style>
<script type="text/javascript">
setTimeout(function(){
var div = document.querySelector("div");
div.classList.add("change");
});
</script>
</head>
<body>
<div></div>
</body>
</html>
比如直接修改style属性来触发
 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js直接修改style属性来触发过渡效果</title>
<style type="text/css">
div{width:100px;height:40px;background:#92b901;transition:width 0.5s;}
</style>
<script type="text/javascript">
setTimeout(function(){
var div = document.querySelector("div");
div.style.width="200px";
});
</script>
</head>
<body>
<div></div>
</body>
</html>

3.通过伪类触发

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js直接修改伪类属性来触发过渡效果</title>
<style type="text/css">
div{width:100px;height:40px;background:#92b901;transition:width 0.5s;}
input:focus ~ div{width:200px;}
</style>
</head>
<body>
<input>
<div></div>
</body>
</html>

利用input获得焦点,可以把一些相应提示信息显示出来

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>input获得焦点,可以把一些相应提示信息显示出来</title>
<style type="text/css">
input:focus ~ p{width:200px;transform:scale(1);}
p{transform:scale(0);transition:transform 0.2s;}
</style>
</head>
<body>
<input>
<p>请输入数字</p>
</body>
</html>

通过active来触发

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>active来触发</title>
<style type="text/css">
button:active ~ p{width:200px;transform:scale(1);}
p{transform:scale(0);transition:transform 0.2s;}
</style>
</head>
<body>
<button>hold me</button>
<p>hahah</p>
</body>
</html>

开关按钮

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
input{display:none;}
label{width:100px;height:50px;background:#ADC14E;display:block;border-radius:25px;}
div{width:50px;height:50px;border-radius:50%;background:#FFF;border:1px solid silver;position:relative;left:0;transition: left 0.5s;}
input:checked ~ div{left:50px;}
</style>
</head>
<body>
<label>
<input type="checkbox">
<div></div>
</label>
</body>
</html>
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIgAAABBCAIAAACFP3t5AAAGiElEQVR4nO2c7WvbRhzH+xcWxiCwsrZ0MDY22F7sxUZfdG86Rhm0r/JirKwvBoVua0qWtF2apEl0dzrrwfbZTqTKUmxJjp+S1nLqWLFj5bYXAc809UNsn3UMffi+NbqfPkiWdHe/S/9EcMmlsAcQ8X4iMZwSieGUSAynRGI4ZcpiOsGxXUI7Bkxv4yQRFVXEGAEAAAAYI0VFamJLJasSefQcf/l463KIWYRzK/JnQuqmot9N7z5wqhud4Hi6Z2MSpiPmsOk4JZzWtmQFAgB0XXddt1KpeJ7n+34QBEEQ+L7veV6lUnFdV9d1AICkAJk82Yh/H66hbpbxtZh2xyou14/yUzktkzCpmPpRzrTXJUVACBmGcXBwcHp6OsoPKaW1Ws0wDISQpGwhci90Mf8ZEq+mrPu1t9kJT84kjC/m6Lhiui/jSQFCUCgURvRxHkppsVgURSTHXwqJH0K30s2K/LlmP2z4xbFP0SSMKaZa246nViCEuVyu0+lMPo4gCGzbhhCqZHVB+DB0K908xdcrb+KTF3hRxhGTL23IqkAIabfb0x1Nu91Op9OSvLmufhu6km6WxI8N909Kg+kWO5iLiWmfHGadNYyBYRiUUhYDopRaliViAMlPoSvpTcq677desyj5vVxADKUBefX72T8KuwGdUSqVIASb6p3QffRGSN2c2XVzATFZZw0AYX9/n91oevE8DwABJPlyk7J+OZ2Jm1HF2KUNjGdxrfRSLpcxFtaUb0L30ZtX7h8zqH0kMYV9UVYFwzBYj+Y8uVxOUjaXxeuh++hmCV2xy2usCx8u5ui4QjIvCSGM/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fFfYFRpUOYJwGDJ1OJ5VKZTKZqe+b6XQ6mqZx0oDhWexGZvcB6/eVfozZsoRSms/nRVF0HGcq65sppYVCQRRFHlqWLMK5RHae6ReXoUzUfcn3fV3XMcblcnmSO1u1Wo1JsdCb/CyhK+L2baOw8IblHr4RmUK/skajQQiJxWKmadZqtRENUUo9z7MsS5IkRUXr8q3ZXxbvNJJrnxxOfjamxdQ6/Pm+7zhOMpkcsZEcQiiZTDqOw+EiKR6Yfk/MVqu1t7dnmqamaWdX0lnrxVgsRgjRNM00zb29vVarNfVD/5+ImpVySiSGUyIxnBKJ4ZRIDKdEYjglEsMp/wIphRjEKWiPBgAAAABJRU5ErkJggg==" alt="" />
如果上面要模拟开关,需要把主要的样式都放在input的兄弟元素上.

CSS3 过渡效果触发时机的问题的更多相关文章

  1. 第八十二节,CSS3过渡效果

    CSS3过渡效果 学习要点: 1.过渡简介 2.transition-property 3.transition-duration 4.transition-timing-function 5.tra ...

  2. CSS3过渡效果实现菜单划出效果

    下载地址 这是大体上的原理,当然案例比这个多 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" & ...

  3. css雪碧(CSS Sprite)和css3过渡效果综合应用

    在网页中我们经常可以看到,有些图片在鼠标经过的时候,有一个上下或左右的滑动效果,很实用页很方便,今天正好用到,拿来和大家分享一下,有什么不对或意见欢迎指正. html部分如下,这里本来打算用jq来着, ...

  4. Spring 高级特性之二:Processor——Bean生命周期关键触发时机

    任何对象都有生命周期,那么Spring Bean对象创建.管理.销毁的整个生命周期个关键触发时机如何体现呢?先说结论,后续案例验证结论. 根据上图可知,实际bean对象涉及生命周期的主要是一个构造器和 ...

  5. 一文聊透 Netty IO 事件的编排利器 pipeline | 详解所有 IO 事件的触发时机以及传播路径

    欢迎关注公众号:bin的技术小屋,本文图片加载不出来的话可查看公众号原文 本系列Netty源码解析文章基于 4.1.56.Final版本 1. 前文回顾 在前边的系列文章中,笔者为大家详细剖析了 Re ...

  6. 第 25 章 CSS3 过渡效果

    学习要点: 1.过渡简介 2.transition-property 3.transition-duration 4.transition-timing-function 5.transition-d ...

  7. Linux用户抢占和内核抢占详解(概念, 实现和触发时机)--Linux进程的管理与调度(二十)

    1 非抢占式和可抢占式内核 为了简化问题,我使用嵌入式实时系统uC/OS作为例子 首先要指出的是,uC/OS只有内核态,没有用户态,这和Linux不一样 多任务系统中, 内核负责管理各个任务, 或者说 ...

  8. CSS3 动画触发事件

    @keyframes mymove { 0% {top:0px; left:0px; background:red;} 25% {top:0px; left:100px; background:blu ...

  9. layoutSubview触发时机

    layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSubviews 2.addSubview会触发layoutSubviews 3.设置view的Frame会触 ...

随机推荐

  1. P2934 [USACO09JAN]安全出行Safe Travel

    P2934 [USACO09JAN]安全出行Safe Travel https://www.luogu.org/problemnew/show/P2934 分析: 建出最短路树,然后考虑一条非树边u, ...

  2. CC2640 LaunchPad入门试用-第一篇

    1. 先安装固件ble_cc26xx_setupwin32_2_01_00_44423.exe. 2. 打开IAR先找到一个例程测试一下D:\ti\simplelink\ble_cc26xx_2_01 ...

  3. 二、StreamAPI

    一.Stream是什么? 是数据通道,用于操作数据源(集合.数组等)所生成的元素序列.集合讲的是数据,流讲的是计算. 注意: Stream不会存储元素. Stream不会改变源对象.相反,他们会返回一 ...

  4. nested class 例子

    #include<iostream> using namespace std; /* start of Enclosing class declaration */ class Enclo ...

  5. BBU+RRU基本介绍

    现代移动通信网络中的数模转化架构:RRU+BBU: 因为学习需要了解RRU+BBU.特此网上查找了一番,找到了一些还不错的解释,分享给大家! BBU与RRU的区别: 通常大型建筑物内部的层间有楼板,房 ...

  6. .NET邮件发送详情

    ①百度下载个Free Smtp Server ②下载完成后,打开进去,点击左上角的options,弹出窗口,进行如下图选项即可(一般默认已正确选中),然后我们可以把这软件关了. (下次你重启电脑时,也 ...

  7. [JSON].result()

    语法:[JSON].result() 返回:[True | False] 说明:用json字符串创建JSON实例时,如果该json字符串不是合法的json格式,会创建一个空的json实例.但是我们如果 ...

  8. Django学习总结-之-URLS反向解析

    2018-09-15  09:58:49 在CSDN博客审核效率提高之前, 又要在此处向各位唠叨了~ URL 与 URI URL : 统一资源定位符 相当于绝对路径 URI : 统一资源标志符 相当于 ...

  9. linux学习总结----redis总结

    安装 下载:打开redis官方网站,推荐下载稳定版本(stable) 解压 tar zxvf redis-3.2.5.tar.gz 复制:推荐放到usr/local目录下 sudo mv -r ...

  10. oracle 学习随笔一: 字段大小写

    字段上加大小写:"reportId"  即可