如何使用纯css制作扇形图,合并起来形成饼图

html-css016

如何使用纯css制作扇形图,合并起来形成饼图,第1张

使用纯css制作扇形图,合并起来形成饼图:

应该知道css3中引入了圆角属性(border-radius),一旦设置这个值,边框即会出现圆角。同样,我们对正方形设置圆角,即可得到饼状图

html:<div id="circle">11</div>

css:

#circle{

width:0

height:0

border-radius:100px

border-width:100px

border-style:solid

border-color: red blue green yellow

line-height:99em

overflow:hidden

cursor:pointer

margin: 30px auto

}

效果:

4.同样我们对其中三个边框设置透明色即可得到扇形

html:<div id="fan">11</div>

css:

#fan{

width:0

height:0

border-radius:100px

border-width:100px

border-style:solid

border-color:red transparent transparent transparent

line-height:99em

overflow:hidden

cursor:pointer

margin: 30px auto

}

效果:

就是将多个小图片合成一张大图片,通过css截取不同部位的区域子图片。

如(这些都是宽为16px的图片,通过css:background-position去截取,这样很多个小图片就合成了一张大图片,减少了http访问次数,还能在一定程度上减小总图片大小):

在一个CSS文件利用@import url('其他的CSS文件')

想引入几个CSS文件就用几个@import url

注意路径的的书写

首页需要两个CSS文件index.css和common.css

就在index.css的首行写入(两个CSS文件在同一个目录下)

@import url('common.css')

这样只需要在首页链接一个index.css文件就可以了。