Use CSS to achieve basic bar chart effects_Experience exchange

WBOY
Release: 2016-05-16 12:06:59
Original
1404 people have browsed it

CSS bar chart is a form that we often encounter in web design. Bar charts can visually represent quantities in the form of bar graphs.
What is the implementation method of basic CSS bar chart? Let's look at the following example:

Copy code The code is as follows:


24%


This is xhtml The code defines a container, applies the class graph, which includes an xhtml element strong, and applies the class bar to this element.
Let’s look at the following CSS definition:
Copy code The code is as follows:

. graph {
position: relative; /* IE is dumb */
width: 200px;
border: 1px solid #B1D632;
padding: 2px;
}
.graph . bar {
display: block;
position: relative;
background: #B1D632;
text-align: center;
color: #333;
height: 2em;
line-height: 2em;
}
.graph .bar span { position: absolute; left: 1em; }

Through the definition of the border and color above, we outline a strip shape. We define the size of the set area in the xhtml code with style="width: 24%;". Such a basic bar chart is complete!
Let’s see the final running effect:

[Ctrl A Select all Note:If you need to introduce external Js, you need to refresh it to execute]
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!