【CSS】button悬停动效汇总

  • HTML
css 复制代码
<div id="container">

  <h1>CSS3 Animated Buttons</h1>

  <button class="highlight"> Highlight</button>
  <button class="fade"> Fade</button>
  <button class="boom"> Boom</button>

  <button class="focus"> Focus</button>
  <button class="rotate"> Rotate</button>
  <button class="knit"> Knit</button>

  <button class="shrink"> Shrink</button>
  <button class="squeeze"> Squeeze</button>
  <button class="deform"> Deform</button>

</div>
  • css
css 复制代码
* {
  margin: 0;
  padding: 0;
  -webkit-backface-visibility: hidden;
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
  transition: all 0.5s;
}

body {
  background-color: #333;
  background: repeating-linear-gradient(45deg, #f6f6f6 0, #f6f6f6 5%, #fff 0, #fff 50%) 0 / 20px 20px;
}

#container {
  width: 330px;
  margin: 25px auto;
}
/*for lack a better headline*/

h1 {
  color: #333;
  font-family: Open Sans Condensed;
  font-size: 2.5em;
  text-align: center;
  margin-bottom: 40px;
}

h1:hover {
  font-size: 2.5em;
}

h1:hover:before,
h1:hover:after {
  font-style: italic;
  font-size: 0.5em;
}

h1:hover:before {
  content: "some ";
}

h1:hover:after {
  content: " by NobodyRocks";
}
/*i'm a button, click me!*/

button {
  width: 100px;
  height: 100px;
  color: #ffffff;
  background-color: #3498db;
  font-family: Open Sans Condensed;
  text-decoration: none;
  font-size: 1.8em;
  border: 2px #ffffff solid;
  margin: 10px 0 0 5px;
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
  transition: all 0.5s;
}
/*magic starts here*/

button:hover {
  cursor: pointer;
}

.highlight:hover {
  background-color: #FFffff;
  color: #3498db;
}

.fade:hover {
  border: 0px;
  color: #009999;
  opacity: 0;
}

.boom:hover {
  color: #009999;
  border: #009999;
  opacity: 0;
  -webkit-transform: scale(2, 2);
  -moz-transform: scale(2, 2);
  transform: scale(2, 2);
}

.focus:hover {
  border-width: 20px;
}

.rotate:hover {
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  transform: rotate(90deg);
}

.knit:hover {
  height: 0px;
}

.shrink:hover {
  -webkit-transform: scale(0.0, 0.0);
  -moz-transform: scale(0.0, 0.0);
  transform: scale(0.0, 0.0);
}

.squeeze:hover {
  -webkit-transform: scale(1.5, 0.0);
  -moz-transform: scale(1.5, 0.0);
  transform: scale(1.5, 0.0);
}

.deform:hover {
  -webkit-transform: skew(45deg, 45deg);
  -moz-transform: skew(45deg, 45deg);
  transform: skew(45deg, 45deg);
}
/*for the sake of responsiveness...*/

@media (max-width: 330px) {
  #container {
    width: 100%;
  }
  button {
    width: 90%;
    margin: 5% 0 0 5%;
  }
}
相关推荐
技术小丁2 小时前
使用 HTML + JavaScript 实现自定义富文本编辑器开发实践(附完整代码)
前端·javascript·html
代码搬运媛5 小时前
React 中 HTML 插入的全场景实践与安全指南
安全·react.js·html
lljss20208 小时前
html文字红色粗体,闪烁渐变动画效果,中英文切换版本
css·html·css3
疯狂的沙粒8 小时前
在web-view 加载的本地及远程HTML中调用uniapp的API及网页和vue页面是如何通讯的?
前端·uni-app·html
小妖6668 小时前
html 滚动条滚动过快会留下边框线
前端·html
CodeBlossom16 小时前
javaweb -html -CSS
前端·javascript·html
鱼馅饼19 小时前
vscode使用系列之快速生成html模板
ide·vscode·html
然我1 天前
JavaScript的OOP独特之道:从原型继承到class语法
前端·javascript·html
木木夕酱1 天前
前端响应式网站编写套路
css·react.js
用户26834842239591 天前
前端换肤功能最佳实践:从基础实现到高级优化
前端·css