效果预览

代码

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="https://www.cnblogs.com/beixuan">
<meta name="version" content="1.0.0">
<meta name="date" content="2021/12/01 18:00:26">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CSS动画大全之按钮组[b]</title>
</head>
<style type="text/css"> /* 设置 body 内、外边距为 0 */
body {
margin: 0;
padding: 0;
display: grid;
grid-template-columns: 100%;
grid-template-rows: 100%;
justify-items: center;
align-items: center;
width: 100vw;
height: 100vh;
background-color: #FFF;
} .page-wrapper {
display: grid;
grid-template-columns: 33% 34% 33%;
grid-template-rows: 100%;
justify-items: center;
align-items: center;
width: 100vw;
height: 100vh;
} .page-wrapper > div {
display: inline-block;
} .btn {
width: 12.5rem;
height: 3.125rem;
line-height: 3.125rem;
font-size: 1.5rem;
padding: 0.5rem;
text-align: center;
box-shadow: 0 0 1px #000;
position: relative;
transition: all 0.5s;
margin-bottom: 1rem;
cursor: pointer;
overflow: hidden;
} .btn:hover {
box-shadow: 0 0 0px #000;
} .btn-danger, .btn-success {
height: 7.85rem;
line-height: 7.85rem;
} /* 默认 */
.btn-default:hover {
color: #00aaff;
} .btn-default::before {
content: '';
width: calc(100% - 10px);
height: 100%;
position: absolute;
border-left: 5px solid #00aaff;
border-right: 5px solid #00aaff;
top: -100%;
left: 0;
transition: all 0.4s;
z-index: -1;
} .btn-default:hover::before {
content: '';
width: calc(100% - 10px);
height: 100%;
position: absolute;
border-left: 5px solid #00aaff;
border-right: 5px solid #00aaff;
top: 0%;
left: 0;
transition: all 0.4s;
z-index: -1;
} .btn-default::after {
content: '';
width: 100%;
height: calc(100% - 10px);
position: absolute;
border-top: 5px solid #00aaff;
border-bottom: 5px solid #00aaff;
top: 0;
left: 100%;
transition: all 0.4s;
z-index: -1;
} .btn-default:hover::after {
content: '';
width: 100%;
height: calc(100% - 10px);
position: absolute;
border-top: 5px solid #00aaff;
border-bottom: 5px solid #00aaff;
top: 0;
left: 0;
transition: all 0.4s;
z-index: -1;
} /* 警告 */
.btn-warning:hover {
color: #ffaa00;
} .btn-warning::before {
content: '';
width: calc(100% - 10px);
height: 100%;
position: absolute;
border-left: 5px solid #ffaa00;
border-right: 5px solid #ffaa00;
top: 100%;
left: 0;
transition: all 0.4s;
z-index: -1;
} .btn-warning:hover::before {
content: '';
width: calc(100% - 10px);
height: 100%;
position: absolute;
border-left: 5px solid #ffaa00;
border-right: 5px solid #ffaa00;
top: 0%;
left: 0;
transition: all 0.4s;
z-index: -1;
} .btn-warning::after {
content: '';
width: 100%;
height: calc(100% - 10px);
position: absolute;
border-top: 5px solid #ffaa00;
border-bottom: 5px solid #ffaa00;
top: 0;
left: 100%;
transition: all 0.4s;
z-index: -1;
} .btn-warning:hover::after {
content: '';
width: 100%;
height: calc(100% - 10px);
position: absolute;
border-top: 5px solid #ffaa00;
border-bottom: 5px solid #ffaa00;
top: 0;
left: 0;
transition: all 0.4s;
z-index: -1;
} /* 失败 */
.btn-danger:hover {
color: #e30000;
} .btn-danger::before {
content: '';
width: calc(100% - 10px);
height: 100%;
position: absolute;
border-left: 5px solid #e30000;
border-right: 5px solid #e30000;
top: -100%;
left: 0;
transition: all 0.4s;
z-index: -1;
} .btn-danger:hover::before {
content: '';
width: calc(100% - 10px);
height: 100%;
position: absolute;
border-left: 5px solid #e30000;
border-right: 5px solid #e30000;
top: 0%;
left: 0;
transition: all 0.4s;
z-index: -1;
} .btn-danger::after {
content: '';
width: 100%;
height: calc(100% - 10px);
position: absolute;
border-top: 5px solid #e30000;
border-bottom: 5px solid #e30000;
top: 0;
left: -100%;
transition: all 0.4s;
z-index: -1;
} .btn-danger:hover::after {
content: '';
width: 100%;
height: calc(100% - 10px);
position: absolute;
border-top: 5px solid #e30000;
border-bottom: 5px solid #e30000;
top: 0;
left: 0;
transition: all 0.4s;
z-index: -1;
} /* 成功 */
.btn-success:hover {
color: #00d064;
} .btn-success::before {
content: '';
width: calc(100% - 10px);
height: 100%;
position: absolute;
border-left: 5px solid #00d064;
border-right: 5px solid #00d064;
top: 100%;
left: 0;
transition: all 0.4s;
z-index: -1;
} .btn-success:hover::before {
content: '';
width: calc(100% - 10px);
height: 100%;
position: absolute;
border-left: 5px solid #00d064;
border-right: 5px solid #00d064;
top: 0%;
left: 0;
transition: all 0.4s;
z-index: -1;
} .btn-success::after {
content: '';
width: 100%;
height: calc(100% - 10px);
position: absolute;
border-top: 5px solid #00d064;
border-bottom: 5px solid #00d064;
top: 0;
left: -100%;
transition: all 0.4s;
z-index: -1;
} .btn-success:hover::after {
content: '';
width: 100%;
height: calc(100% - 10px);
position: absolute;
border-top: 5px solid #00d064;
border-bottom: 5px solid #00d064;
top: 0;
left: 0;
transition: all 0.4s;
z-index: -1;
} </style>
<body>
<!-- 页面容器 -->
<div class="page-wrapper">
<div class="btn btn-danger">失败 Left</div>
<div>
<div class="btn btn-default">默认 Top</div>
<div class="btn btn-warning">警告 Bottom</div>
</div>
<div class="btn btn-success">成功 Right</div>
</div>
</body>
</html>

往期回顾

【全】一、CSS动画大全之按钮组【a】

【全】一、CSS动画大全之按钮组【b】

【全】CSS动画大全之按钮【c】的更多相关文章

  1. 【2016年特别福利】史上最全CSS学习资料大全

    css学习篇 [2016年特别福利]史上最全CSS学习资料大全

  2. 原生html,css+js写下载按钮有提示动画效果的落地页

    <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8&q ...

  3. 这样使用 GPU 渲染 CSS 动画(转)

    大多数人知道现代网络浏览器使用GPU来渲染部分网页,特别是具有动画的部分. 例如,使用transform属性的CSS动画看起来比使用left和top属性的动画更平滑. 但是如果你问,“我如何从GPU获 ...

  4. Web高性能动画及渲染原理(1)CSS动画和JS动画

    目录 一. CSS动画 和 JS动画 1.1 CSS动画 1.2 JS动画 1.3 小结 二. 使用Velocity.js实现动画 示例代码托管在:http://www.github.com/dash ...

  5. 高性能Web动画和渲染原理系列(1)——CSS动画和JS动画

    [摘要] 介绍CSS动画和JS动画的基本特点,以及轻量级动画库velocity.js的基本用法. 示例代码托管在:http://www.github.com/dashnowords/blogs 博客园 ...

  6. JS框架_(JQuery.js)文章全屏动画切换

    百度云盘 传送门 密码:anap 文章全屏动画切换效果 <!doctype html> <html lang="zh"> <head> < ...

  7. Css 动画的回调

    在做项目中经常会遇到使用动画的情况.以前的情况是用js写动画,利用setTimeout函数或者window.requestAnimationFrame()实现目标元素的动画效果.虽然后者解决了刷新频率 ...

  8. [转]CSS hack大全&详解

    转自:CSS hack大全&详解 1.什么是CSS hack? CSS hack是通过在CSS样式中加入一些特殊的符号,让不同的浏览器识别不同的符号(什么样的浏览器识别什么样的符号是有标准的, ...

  9. CSS动画与GPU

    写在前面 满世界的动画性能优化技巧,例如: 只允许改变transform.opacity,其它属性不要动,避免重新计算布局(reflow) 对动画元素应用transform: translate3d( ...

  10. 15个来自 CodePen 的酷炫 CSS 动画效果【下篇】

    CodePen 是一个在线的前端代码编辑和展示网站,能够编写代码并即时预览效果.你在上面可以在线分享自己的 Web 作品,也可以欣赏到世界各地的优秀开发者在网页中实现的各种令人惊奇的效果. 今天这篇文 ...

随机推荐

  1. 向Web服务器端上传文件

    server.py import flaskapp = flask.Flask(__name__)@app.route('/upload', methods=['POST'])def uploadFi ...

  2. js中对对象经行判空

    1.for (... in ...) for(var i in obj){ return true; //如果不为空,返回true } return false; //如果为空,返回false 2.J ...

  3. IEC103设备数据 转 IEC61850项目案例

    目录 1 案例说明 1 2 VFBOX网关工作原理 1 3 准备工作 2 4 配置VFBOX网关采集103设备数是 2 5 用IEC61850协议转发数据 4 6 网关使用多个逻辑设备和逻辑节点的方法 ...

  4. 实测52.4MB/s!全国产ARM+FPGA的CSI通信案例分享!

    CSI总线介绍与优势 CSI(CMOS sensor parallel interfaces)总线是一种用于连接图像传感器和处理器的并行通信接口,应用于工业自动化.能源电力.智慧医疗等领域,CSI总线 ...

  5. 实时系统Preempt RT与Xenomai之争!谁更主流,谁更实时?

    选择争论一直存在 大家知道EtherCAT是实时现场总线技术,当我们开发一款支持EtherCAT总线的控制器时,实时操作系统的选择不仅对于产品本身是最重要的一部分,而且对产品研发的整个过程也影响深远. ...

  6. CF1137C 题解

    考虑把每个点进行拆成 \(d\) 个点表示星期几走到这个点,那么原图上的边 \((u,v)\) 就被拆成\((pos_{u,i},pos_{v,i+1})\) 表示星期的变化. 然后考虑进行缩点,在一 ...

  7. 使用post请求登陆

    1.使用post请求登陆 import requests import matplotlib.pyplot as plt url = 'https://www.ptpress.com.cn/login ...

  8. 实用!一键生成数据库文档的神器,支持MySQL/SqlServer/Oracle多种数据库

    Screw(螺丝钉)是一款简洁好用的数据库表结构文档生成工具,它的特点是:简洁.轻量.设计良好.多数据库支持.多种格式文档.灵活扩展以及支持自定义模板,对于有经常要进行数据库设计.评审.文档整理等需求 ...

  9. 将mysql的查询结果保存到文件中,并将文件从内网下载到外网服务器

    方法一: 直接执行命令: mysql> SELECT ordersid from yws.callback_clockd  ORDER BY ordersid ASC limit 0,10000 ...

  10. C#:只支持GET和POST方法的浏览器,如何发送PUT/DELETE请求?RESTful WebAPI如何响应?

    理想的RESTful WebAPI采用面向资源的架构,并使用请求的HTTP方法表示针对目标资源的操作类型.但是理想和现实是有距离的,虽然HTTP协议提供了一系列原生的HTTP方法,但是在具体的网络环境 ...