Created
May 19, 2012 21:24
-
-
Save slivero/2732448 to your computer and use it in GitHub Desktop.
Styling the HTML5 Meter Tag Using the Shadow DOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style type="text/css"> | |
article { | |
width:520px; | |
height:170px; | |
margin: 30px auto; | |
font-family: Arial, sans-serif; | |
color: #2146CA; | |
font-size:17px; | |
background: -webkit-linear-gradient(top, rgba(219,237,239,0) 10%,rgba(219,237,239,0.7) 90%,rgba(219,237,239,1) 99%,rgba(219,237,239,1) 100%); | |
} | |
.column { | |
float: left; | |
width:240px; | |
margin: auto; | |
} | |
.column.left { | |
margin: 0 0 0 30px; | |
} | |
.column.right { | |
position: relative; | |
} | |
dt { | |
font-weight:bold; | |
float: left; | |
width:110px; | |
height:25px; | |
} | |
dd { | |
float: left; | |
width:80px; | |
height:25px; | |
} | |
/* The main meter element and star */ | |
#raised { | |
-webit-style:none; | |
position: relative; | |
background-image:url(star.svg); | |
height:150px; | |
width:150px; | |
position: absolute; | |
right:20px; | |
} | |
/* The overlay shadow */ | |
#raised:before { | |
content: ''; | |
background-color:#fff; | |
opacity: 0.2; | |
height:60; | |
width:115; | |
position: absolute; | |
top:0; | |
left:17.5px; | |
z-index:5; | |
margin: 16px 0 0 0; | |
border-radius: 100px; | |
border-bottom-right-radius: 10px; | |
border-bottom-left-radius: 10px; | |
} | |
/* The percentage */ | |
#raised:after { | |
content: "60%"; | |
position: absolute; | |
top:65px; | |
right:36%; | |
font-family: Arial, sans-serif; | |
font-weight:bold; | |
color: #fff; | |
} | |
/** | |
* Shadow Dom Elements | |
*/ | |
/* The central circle */ | |
#raised::-webkit-meter-bar { | |
-webkit-transform: rotate(270deg); | |
-webkit-mask-image: url(circle.svg); | |
background:none; | |
margin: 25px 0 00px 25; | |
width:100px; | |
height:100px; | |
} | |
/* The area of the meter indicating the value */ | |
#raised::-webkit-meter-optimum-value { | |
background:#134A6F; | |
} | |
</style> | |
</head> | |
<body> | |
<article> | |
<div class="column left"> | |
<dl> | |
<dt>Target:</dt> | |
<dd>£200</dd> | |
<dt>Raised so far:</dt> | |
<dd>£120</dd> | |
</dl> | |
</div> | |
<div class="column right"> | |
<meter id="raised" min="0" max="200" value="120" title="pounds">60%</meter> | |
</div> | |
</article> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment