Skip to content

Instantly share code, notes, and snippets.

@obenjiro
Last active December 29, 2015 22:49
Show Gist options
  • Save obenjiro/7738946 to your computer and use it in GitHub Desktop.
Save obenjiro/7738946 to your computer and use it in GitHub Desktop.
CSS progress bar ( incomplete and not perfect )
/* you can test this control using this link
** http://jsbin.com/orePosUh/4
**
** some test results
** http://www.browserstack.com/screenshots/194bf28709cddb6b361017a813e18d420f0a2c9c
*/
.progress_common {
width:220px;
height:15px;
border-radius: 10px;
cursor: default;
}
.progress_text {
/* http://www.w3schools.com/cssref/css_websafe_fonts.asp */
font-family: Verdana, Geneva, sans-serif;
font-size: 9px;
/* line-height must be equal to .progress_common.height */
line-height: 15px;
position:absolute;
text-align: center;
}
.progress_component {
position:relative;
background: white;
border: 1px solid #f7f7f7;
/* inner shadow */
-moz-box-shadow: inset 0px 1px 2px 0px #2f2f2f;
-webkit-box-shadow: inset 0px 1px 2px 0px #2f2f2f;
box-shadow: inset 0px 1px 2px 0px #2f2f2f;
/* disabling text selection */
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* http://www.colorzilla.com/gradient-editor/ */
.progress {
color: transparent;
position:absolute;
background: #acff58; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2FjZmY1OCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUxJSIgc3RvcC1jb2xvcj0iIzI4YmYxNCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9Ijg2JSIgc3RvcC1jb2xvcj0iIzhhZGExYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMyOGJmMTQiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #acff58 0%, #28bf14 51%, #8ada1a 86%, #28bf14 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#acff58), color-stop(51%,#28bf14), color-stop(86%,#8ada1a), color-stop(100%,#28bf14)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #acff58 0%,#28bf14 51%,#8ada1a 86%,#28bf14 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #acff58 0%,#28bf14 51%,#8ada1a 86%,#28bf14 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #acff58 0%,#28bf14 51%,#8ada1a 86%,#28bf14 100%); /* IE10+ */
background: linear-gradient(to bottom, #acff58 0%,#28bf14 51%,#8ada1a 86%,#28bf14 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#acff58', endColorstr='#28bf14',GradientType=0 ); /* IE6-8 */
}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if gte IE 9]>
<style type="text/css">
.gradient {
filter: none !important;
}
</style>
<![endif]-->
</head>
<body>
<div class='progress_component progress_common'>
<span class='progress progress_common gradient' style='width:25%'>Progress - </span>
<span class='progress_text progress_common'>25%</span>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment