Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
lt;div class="sector"></div>
.sector{
width: 200px;
height: 200px;
border-radius: 200px;
background-color: deepskyblue;
position: relative;
}
.sector::before{
content: "";
width: 200px;
height: 200px;
position: absolute;
background-color: white;
border-radius: 200px;
/*裁減半圓,再做旋轉*/
clip: rect(0px,100px,200px,0);
transform: rotate(-60deg);
}
.sector::after{
content: "";
width: 200px;
height: 200px;
position: absolute;
background-color: white;
border-radius: 200px;
/*裁減半圓,再做旋轉*/
clip: rect(0px,200px,200px,100px);
transform: rotate(60deg);
}
方式二
<>
<style>
#demo {
position: relative;
width: 50px;
height: 50px;
overflow: hidden;
}
#circle {
position: absolute;
width: 100px;
height: 100px;
background-color: black;
border-radius: 50%;
}
</style>
<body>
<div id="demo">
<div id="circle"></div>
</div>
</body>
</>
方式三
網上統計圖插件非常多,比如Echarts、Chart.js等,但是如果你要的是功能簡單,單一的統計圖,應用這些就會很浪費,也增加自身體積,如果你想要簡單的扇形統計圖,請看過來!
Canvas繪制扇形統計圖,50行代碼的統計圖
Canvas繪制扇形統計圖,50行代碼的統計圖
Canvas繪制扇形統計圖,50行代碼的統計圖
Canvas繪制扇形統計圖,50行代碼的統計圖
// 示例一 drawCircle({ id: 'one',//dom元素 color: '#10af7e',//顏色 bgLine: '#e4e4e4',//背景顏色 angle: 0.5,//所占比例 lineWidth: 15,//寬度(像素) lineCap: 'round'//描邊的樣式 }); // 示例二 drawCircle({ id: 'two', angle: 0.75, color: '#49b1f5', bgLine: '#f3766f', lineWidth: 20 }); // 示例三 drawCircle({ id: 'three', angle: 1, lineWidth: 25, color: 'grd' });
這里的css主要是用來[示例頁面](http://demo.javanx.cn/canvas-charts/)布局的,可以直接忽略
.box ul, .box li { list-style: none; margin: 0; padding: 0; } .box ul li { float: left; width: 33%; text-align: center; }
需要源碼和演示地址的同學,點擊下方“了解更多”!
更多資源敬請關注!
ss3給我們前端開發帶來了很便利, 我們可以使用css3
*請認真填寫需求信息,我們會在24小時內與您取得聯系。