Skip to content

Instantly share code, notes, and snippets.

@kurtsson
Last active August 29, 2015 14:08
Show Gist options
  • Save kurtsson/00bb07fab79a762b2712 to your computer and use it in GitHub Desktop.
Save kurtsson/00bb07fab79a762b2712 to your computer and use it in GitHub Desktop.
A battery icon made purly in CSS, heavily influated by the battery from @captainbrosset
.battery {
$bg: $bright-color;
$border: $dark-color;
$level-good: $green;
$level-bad: $red;
font-size: 2px;
display: inline-block;
width: 4.5em;
height: 11em;
border: 0.8em solid $bg;
box-shadow: 0 0 0 1px $border;
margin: 1em 1.5em 0 1.5em;
position: relative;
background-color: $level-good;
background-size: 100%;
&:before {
position: absolute;
top: -2em;
left: 0em;
display: block;
background: $border;
width: 3.4em;
height: 1em;
content : "";
border-radius: 1em 1em 0 0;
}
&:after {
position: absolute;
top: 0em;
left: -0.6em;
display: block;
background: $bg;
width: 4.5em;
height: 0;
content : "";
}
&.good {
&:after {
height: 2.2em;
}
}
&.bad {
&:after {
height: 6em;
}
}
&.bad, &.critical {
background-color: $level-bad;
}
&.critical {
&:after {
height: 8em;
}
}
}
@kurtsson
Copy link
Author

Thanks to @captainbrosset (https://github.com/captainbrosset) for his example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment