网站首页 > 技术文章 正文
制作这几个很常用的CSS3网页小效果。最近写JS的时间比例比较多,不过我还是比较钟情于CSS3。所以我还是坚持分享一些实用的CSS3小例子。
正文
第一种效果:
由于录制gif图片会掉帧,所以看起来不流畅,很卡,但其实实际效果还是不错的,有弹性一些。
html代码:
<span class="shake">弹</span>
css代码:
.shake{ width:40px; height:40px; display:block; background:lightgreen; border-radius:50%; margin:5px; color:#fff; font-size:24px; text-align:center; line-height:40px; cursor:pointer; -webkit-transition:all 0.25s; }.shake:hover{ -webkit-animation:shake 0.25s; background: lightblue; }@-webkit-keyframes shake{ 0%,10%,55%,90%,94%,98%,100%{ -webkit-transform:scale(1,1); } 30%{ -webkit-transform:scale(1.14,0.86); } 75%{ -webkit-transform:scale(0.92,1.08); } 92%{ -webkit-transform:scale(1.04,0.96); } 96%{ -webkit-transform:scale(1.02,0.98); } 99%{ -webkit-transform:scale(1.01,0.99); }}
昨晚看到某人的个人博客网站的回到顶部按钮悬浮效果就是这样子的,还是比较有趣的,不过人家的效果可能比我的好一些,大家不妨试一下。
第二种效果:
这种效果其实目前线上很多网站都在用了,不管是使用CSS3,还是jQuery,都是可以实现的。那这里我只是简单地使用CSS3来实现。
html代码:
<input class="search" type="text" placeholder="搜索...">
CSS代码:
.search{ width:80px; height:40px; border-radius:40px; border:2px solid lightblue; position: absolute; right:200px; outline:none; text-indent:12px; color:#666; font-size:16px; padding:0; -webkit-transition:width 0.5s; }.search:focus{ width:200px; }
一般旁边都会有一个按钮,这里我就不做了。
第三种效果:
这种效果也是很常用,比较多还是个人网站偏多。
html代码:
<div class="banner"> <a href="javascript:;">博</a> <span>这是我的个人博客</span></div>
css代码:
.banner{ width:234px; height:34px; border-radius:34px; position:absolute; top:400px; left:200px; }.banner a{ display:inline-block; width:30px; height:30px; line-height:30px; border-radius:50%; border:2px solid lightblue; position:absolute; left:0px;top:0px; background:lightgreen; color:#fff; text-align:center; text-decoration:none; cursor:pointer; z-index:2; }.banner a:hover + span{ -webkit-transform:rotate(360deg); opacity:1; }.banner span{ display:inline-block; width:auto; padding:0 20px; height:34px; line-height:34px; background:lightblue; border-radius:34px; text-align: center; position:absolute; color:#fff; text-indent:25px; opacity:0; -webkit-transform-origin:8% center; -webkit-transition:all 1s; }
限时!!免费送Dreamweaver、js等前端教程
猜你喜欢
- 2024-12-26 现代CSS:纯 CSS 实现路径动画 js路径动画
- 2024-12-26 用几行原生JS就可以实现丝滑的元素过渡效果
- 2024-12-26 HTML5引领网页开发新概念 html5设计网页
- 2024-12-26 一篇文章教会你利用html5和css3实现3D立方体效果图
- 2024-12-26 WEB:讲清楚CSS、Less、Sass、Scss
- 2024-12-26 Slideout.js – 滑出式 Web App 导航菜单
- 2024-12-26 Android与IOS的的兼容总结 android和ios
- 2024-12-26 CSS渐变属性的特效 css渐变属性的特效有哪些
- 2024-12-26 改进网站设计的免费jQuery插件Top 7
- 2024-12-26 应用HTML5和CSS3实现举报中心PC端与手机端举报页面的自适应设计
- 02-21走进git时代, 你该怎么玩?_gits
- 02-21GitHub是什么?它可不仅仅是云中的Git版本控制器
- 02-21Git常用操作总结_git基本用法
- 02-21为什么互联网巨头使用Git而放弃SVN?(含核心命令与原理)
- 02-21Git 高级用法,喜欢就拿去用_git基本用法
- 02-21Git常用命令和Git团队使用规范指南
- 02-21总结几个常用的Git命令的使用方法
- 02-21Git工作原理和常用指令_git原理详解
- 最近发表
- 标签列表
-
- cmd/c (57)
- c++中::是什么意思 (57)
- sqlset (59)
- ps可以打开pdf格式吗 (58)
- phprequire_once (61)
- localstorage.removeitem (74)
- routermode (59)
- vector线程安全吗 (70)
- & (66)
- java (73)
- org.redisson (64)
- log.warn (60)
- cannotinstantiatethetype (62)
- js数组插入 (83)
- resttemplateokhttp (59)
- gormwherein (64)
- linux删除一个文件夹 (65)
- mac安装java (72)
- reader.onload (61)
- outofmemoryerror是什么意思 (64)
- flask文件上传 (63)
- eacces (67)
- 查看mysql是否启动 (70)
- java是值传递还是引用传递 (58)
- 无效的列索引 (74)