效果预览

代码

<!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. Niagara 物联网技术基础应用(文章修复中,不定时更新)

    新手指南 前言 鉴于市面上有关Niagara物联网技术资料较少,笔者结合自生参加竞赛的经历编写此指南,该指南旨在让新手快速上手Niagara workbench 主要分以下几个模块讲解: 物联网软件平 ...

  2. Exception:kylin构建cube, Cannot modify mapReduce.queue.name at runtime

    Failed to open new session: java.lang.IllegalArgumentException: Cannot modify tez.queue.name at runt ...

  3. 聊一聊 Monitor.Wait 和 Pluse 的底层玩法

    一:背景 1. 讲故事 在dump分析的过程中经常会看到很多线程卡在Monitor.Wait方法上,曾经也有不少人问我为什么用 !syncblk 看不到 Monitor.Wait 上的锁信息,刚好昨天 ...

  4. MestReNova14.0中文版安装教程

    MestReNova 14是一款专业级的核磁共振(NMR)与质谱(MS)数据分析软件,专注于化合物结构解析和验证.该软件以卓越的谱图处理能力和智能化算法为核心,提供自定义参数调整.自动峰识别.精准积分 ...

  5. Project Euler 1~10 野蛮题解

    这些题都比较简单就不贴代码和做法了 23333333 具体到做法就是枚举暴力,这十题中可能难一点地方的就是筛质数表,可以学习一下 Eratosthenes 筛法或者是欧拉筛. 如果您不会前十题建议好好 ...

  6. python重拾第六天-面向对象基础

    本节内容:   面向对象编程介绍 为什么要用面向对象进行开发? 面向对象的特性:封装.继承.多态 类.方法.   引子 你现在是一家游戏公司的开发人员,现在需要你开发一款叫做<人狗大战>的 ...

  7. Linux 内核:设备驱动模型 学习总结

    背景 其实之前就转载过别人针对Linux的设备驱动模型(Linux Device Driver Model,LDDM)的文章,但是受限于自身的能力,因此花了点时间重新学习了一下. 前人写的文章很好,我 ...

  8. C# pythonnet(3)_Butter-worth低通滤波

    Python代码如下 import pandas as pd import numpy as np import matplotlib.pyplot as plt from scipy import ...

  9. 创建基于kotlin开发环境的spring项目入门

    kotlin是idea所属公司开发的一门jvm语言,如果你不了解估计也不会看这里,所以我就不多说了. 这里简单说一下如何新建一个小的kotlin spring项目.kotlin和idea是一家公司,所 ...

  10. GCC8 编译优化 BUG 导致的内存泄漏

    1. 背景 1.1. 接手老系统 最近我们又接手了一套老系统,老系统的迭代效率和稳定性较差,我们打算做重构改造,但重构周期较长,在改造完成之前还有大量的需求迭代.因此我们打算先从稳定性和迭代效率出发做 ...