In the past, when I wrote a column chart, I used an image with a width of 1 px and assigned a percentage to width. I wanted to write a gradient with CSS when I wrote a small statistic last night!
1. Use a plotting tool to make a gradient length. It looks nice (width: 187px; Height: 15px)
2. the original assumption is that when 12%, the image is displayed from left to 12%, and the remaining 88% is not displayed, but it does not cover an area (It looks similar to the 1px image bottom ). at noon, I caught a class. it is unlikely that the domain name is not occupied.
3. To hide the remaining percentage of the image, you first think about scoring. A picture is used for brightness and darkness, half of the total Image Height. I wrote:
<Div style = "Background: URL (...) 12% left; width: 187px; Height: 15px;"> </div>
From 10% to 100% in sequence, the effect is not displayed. For <span> </span>, the content must be included in the box.
4. I did not write it out last night. Google did not find the Class 4 gradient in the afternoon, but I got inspiration from one of the examples.
URL: http://apples-to-oranges.com/blog/post/css-for-bar-graphs? Id = 55
In: complex CSS bar graph
Now we get this:
- <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <HTML xmlns = "http://www.w3.org/1999/xhtml">
- <Head>
- <Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
- <Title> untitled document </title>
- <Style type = "text/CSS">
- DL {margin: 0; padding: 0; width: 187px ;}
- Dd {position: relative; display: block; float: Left; width: 187px; Height: 15px; margin: 0; Border: 1px solid # Eee ;}
- * HTML dd {float: none ;}
- Dd Div {position: relative; Background: URL ("../image/default/percent.gif"); Height: 15px; width: 100%; text-align: Right ;}
- </Style>
- </Head>
- <Body>
- <DL>
- <DD>
- <Div style = "width: 5%;"> </div>
- </DD>
- </Dl>
- <DL>
- <DD>
- <Div style = "width: 15%;"> </div>
- </DD>
- </Dl>
- <DL>
- <DD>
- <Div style = "width: 25%;"> <strong> 55% </strong> </div>
- </DD>
- </Dl>
- <DL>
- <DD>
- <Div style = "width: 35%;"> <strong> 55% </strong> </div>
- </DD>
- </Dl>
- <DL>
- <DD>
- <Div style = "width: 45%;"> <strong> 55% </strong> </div>
- </DD>
- </Dl>
- <DL>
- <DD>
- <Div style = "width: 55%;"> <strong> 55% </strong> </div>
- </DD>
- </Dl>
- <DL>
- <DD>
- <Div style = "width: 65%;"> <strong> 65% </strong> </div>
- </DD>
- </Dl>
- <DL>
- <DD>
- <Div style = "width: 75%;"> <strong> 75% </strong> </div>
- </DD>
- </Dl>
- <DL>
- <DD>
- <Div style = "width: 85%;"> <strong> 85% </strong> </div>
- </DD>
- </Dl>
- <DL>
- <DD>
- <Div style = "width: 95%;"> <strong> 95% </strong> </div>
- </DD>
- </Dl>
- <DL>
- <DD>
- <Div style = "width: 100%;"> <strong> 100% </strong> </div>
- </DD>
- </Dl>
- </Body>
- </Html>
For more information, see