CSS: creating a gradient statistics Column

Source: Internet
Author: User

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:

  1. <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <HTML xmlns = "http://www.w3.org/1999/xhtml">
  3. <Head>
  4. <Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
  5. <Title> untitled document </title>
  6. <Style type = "text/CSS">
  7. DL {margin: 0; padding: 0; width: 187px ;}
  8. Dd {position: relative; display: block; float: Left; width: 187px; Height: 15px; margin: 0; Border: 1px solid # Eee ;}
  9. * HTML dd {float: none ;}
  10. Dd Div {position: relative; Background: URL ("../image/default/percent.gif"); Height: 15px; width: 100%; text-align: Right ;}
  11. </Style>
  12. </Head>
  13. <Body>
  14. <DL>
  15. <DD>
  16. <Div style = "width: 5%;"> </div>
  17. </DD>
  18. </Dl>
  19. <DL>
  20. <DD>
  21. <Div style = "width: 15%;"> </div>
  22. </DD>
  23. </Dl>
  24. <DL>
  25. <DD>
  26. <Div style = "width: 25%;"> <strong> 55% </strong> </div>
  27. </DD>
  28. </Dl>
  29. <DL>
  30. <DD>
  31. <Div style = "width: 35%;"> <strong> 55% </strong> </div>
  32. </DD>
  33. </Dl>
  34. <DL>
  35. <DD>
  36. <Div style = "width: 45%;"> <strong> 55% </strong> </div>
  37. </DD>
  38. </Dl>
  39. <DL>
  40. <DD>
  41. <Div style = "width: 55%;"> <strong> 55% </strong> </div>
  42. </DD>
  43. </Dl>
  44. <DL>
  45. <DD>
  46. <Div style = "width: 65%;"> <strong> 65% </strong> </div>
  47. </DD>
  48. </Dl>
  49. <DL>
  50. <DD>
  51. <Div style = "width: 75%;"> <strong> 75% </strong> </div>
  52. </DD>
  53. </Dl>
  54. <DL>
  55. <DD>
  56. <Div style = "width: 85%;"> <strong> 85% </strong> </div>
  57. </DD>
  58. </Dl>
  59. <DL>
  60. <DD>
  61. <Div style = "width: 95%;"> <strong> 95% </strong> </div>
  62. </DD>
  63. </Dl>
  64. <DL>
  65. <DD>
  66. <Div style = "width: 100%;"> <strong> 100% </strong> </div>
  67. </DD>
  68. </Dl>
  69. </Body>
  70. </Html>

For more information, see

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.