原文地址:https://segmentfault.com/a/1190000014669547

右边多出来的是 :after 的border

HTML代码:

<div class="battery"></div>

CSS代码:

html, body {
margin:;
padding:;
height: 100%;
display:flex;
justify-content: center;
align-items: center;
/*background: linear-gradient(to bottom, teal, aqua); */
}
.battery{
width: 6em;
height: 3em;
color: midnightblue;
border: 0.5em solid currentColor;
border-radius: 0.2em;
font-size: 2em;
position: relative;
/* 充电颜色 */
background-image: linear-gradient(to right, green, green);
background-repeat: no-repeat;
    /* 充电图像大小 */
    background-size: 30% 80%;
/* 给内部充电图像定位 */
background-position: top 0.3em left 0.3em;
animation: charge 5s steps(8) infinite;
}
.battery::after{
position: absolute;
content: '';
width: 0.5em;
height: 2em;
background-color: currentColor;
top: 0.5em;
right: -1em;
border-radius: 0 0.2em 0.2em 0;
}
@keyframes charge {
from {
background-size: 10% 80%;
}
to {
background-size: 95% 80%;
}
}

最新文章

  1. 博弈SG
  2. node.js使用汇总贴
  3. Android 主页面顶部栏的通知Notification ,可以自定义通知消息栏的风格,并且点击通知栏进人本程序。
  4. C# 制作外挂常用的API
  5. 一步一步学android控件(之二十五)—— SeekBar
  6. navigationController显示隐藏问题
  7. VMware vCenter Converter 使用,Error code: 2147549183 (0x8000FFFF) 解决方案
  8. lightoj 1408 Batting Practice
  9. 仿ios版微信应用源代码
  10. VirtualBox 不能为虚拟电脑打开一个新的任务 可能的解决方案
  11. asp读取指定目录下的文件名
  12. android BLE Peripheral 模拟 ibeacon 发出ble 广播
  13. Windows 10的最新版1803版本ISO下载
  14. eclipse下Spring环境构建及插件
  15. openssl 交叉编译
  16. P1734 最大约数和
  17. 第十章&#160;优先级队列 (xa1)左式堆:结构
  18. 常见的mysql 进程state&lt;转自网络&gt;
  19. Spring Cloud Zuul与网关中间件
  20. mac版sublime 无法下载插件(Vue 代码无高亮问题)

热门文章

  1. Git的一些东西(后续补充)
  2. 前端学PHP之面向对象系列第四篇-----关键字
  3. python和linux如何学习一门新的编程语言(python)(python基础结构)
  4. DS二叉树--左叶子数量
  5. Temporary ASP.NET Files\root 空间增长太快
  6. 关于Java大数操作(BigInteger、BigDecimal)
  7. nginx - 性能优化,突破十万并发
  8. VBScript Scripting Techniques: File Open Dialog http://www.robvanderwoude.com/vbstech_ui_fileopen.php
  9. text clf rnn
  10. 头皮溢脂性皮炎推荐联合治疗:采乐50ml+希尔生100g(请看详情页)维生素B2维生素B6