1
2
3
数据可视化主要目的:借助于图像化手段,清晰有效地传达与沟通信息
先引入flexible.js
(function flexible (window, document) {
var docEl = document.documentElement
var dpr = window.devicePixelRatio || 1
// adjust body font size
function setBodyFontSize () {
if (document.body) {
document.body.style.fontSize = (12 * dpr) + 'px'
}
else {
document.addEventListener('DOMContentLoaded', setBodyFontSize)
}
}
setBodyFontSize();
// set 1rem = viewWidth / 10
function setRemUnit () {
var rem = docEl.clientWidth / 10
docEl.style.fontSize = rem + 'px'
}
setRemUnit()
// reset rem unit on page resize
window.addEventListener('resize', setRemUnit)
window.addEventListener('pageshow', function (e) {
if (e.persisted) {
setRemUnit()
}
})
// detect 0.5px supports
if (dpr >= 2) {
var fakeBody = document.createElement('body')
var testElement = document.createElement('div')
testElement.style.border = '.5px solid transparent'
fakeBody.appendChild(testElement)
docEl.appendChild(fakeBody)
if (testElement.offsetHeight === 1) {
docEl.classList.add('hairlines')
}
docEl.removeChild(fakeBody)
}
}(window, document))
屏幕展示效果为1920px
flexible.js默认将屏幕划分为10等份,1920/10=192px,相当于1rem=192px
这里修改为24等份,1924/24=80,相当于1rem=80px
改完之后就会自动转换为 80px=1rem
// css初始化
*{
margin:0;
padding: 0;
box-sizing: border-box; //padding和border的值就不会在影响元素的宽高
}
body{
background: url(../images/bg.jpg) //背景图
no-repeat top center; //不会出现平铺或者重复的现象,位于上部的居中位置
line-height: 1.15; //行高
}
数据可视化-Echarts
header{
position: relative;
height: 1.25rem;
background: url(../images/head_bg.png)
no-repeat;
background-size: 100% 100%; //缩放 水平100% 垂直100%
h1{
font-size: .475rem;
color: #fff;
text-align: center; //文字居中
line-height: 1rem; //行高
}
.showTime{
position: absolute; //绝对位置 (子绝父相)
right: .375rem;
top: 0;
line-height: .9375rem;
color: rgba(255,255,255,0.7);
font-size: .25rem;
}
}
div、section、article,语义上从无到有,逐渐增强; div无任何语义,仅仅用作样式化或者脚本化,对于一段主题性的内容,比较适用section,而假设这段内容是可以脱离上下文,作为完整的结构体独立存在的一段内容,那么就适合用article
1
2
3
// 页面主题盒子
.mainbox{
display: flex;
min-width: 1024px;
max-width: 1920px;
// height: 300px;
margin: 0 auto; //居中对齐
background-color: pink;
padding: .125rem .125rem 0; //上左右10px
.column{
flex: 3; //每个盒子占3份
&:nth-child(2){ //给第二个盒子占5份
flex: 5;
}
}
// .column:nth-child(2){ //给第二个盒子占5份
// flex: 5;
// }
}
.mainbox{
.panel{
position: relative;
height: 3.875rem;
// background-color: pink;
border:1px solid rgba(25, 186, 139, 0.17);
padding: 0 .1875rem .5rem ;
margin-bottom: .1875rem;
background: url(../images/line.png)
rgba(255, 255, 255, 0.03);
&::before{
position: absolute;
top:0;
left:0;
width: 10px;
height: 10px;
border-left: 2px solid #e3ebeb;
border-top: 2px solid #e3ebeb ;
content: "";
}
&::after{
position: absolute;
top:0;
right:0;
width: 10px;
height: 10px;
border-right: 2px solid #e3ebeb;
border-top: 2px solid #e3ebeb ;
content: "";
}
.panel-footer{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
&::before{
position: absolute;
bottom:0;
left:0;
width: 10px;
height: 10px;
border-left: 2px solid #e3ebeb;
border-bottom: 2px solid #e3ebeb ;
content: "";
}
&::after{
position: absolute;
bottom:0;
right:0;
width: 10px;
height: 10px;
border-right: 2px solid #e3ebeb;
border-bottom: 2px solid #e3ebeb ;
content: "";
}
}
}
}
折线图-就业行业
图标
饼形图-就业行业
图标
.mainbox{
.panel{
h2{
height: .6rem;
color: #fff;
line-height: .6rem;
text-align: center;
font-size: .25rem;
font-weight: 5rem;
}
.chart{
height: 3rem;
background-color: pink;
}
}
}
把li的小圆点去掉
声明图标字体
- 1
- 2
- 需求人数
- 供应人数
// no数字模块
.no{
background: rgba(101, 132, 226, 0.1);
padding: .1875rem;
.no-hd{
position: relative;
border: 1px solid rgba(25,186,139,0.17);
&::before{
position: absolute;
top: 0;
left: 0;
content: "";
width: 30px;
height: 10px;
border-top: 2px solid #02a6b5;
border-left: 2px solid #02a6b5;
}
&::after{
position: absolute;
bottom: 0;
right: 0;
content: "";
width: 30px;
height: 10px;
border-bottom: 2px solid #02a6b5;
border-right: 2px solid #02a6b5;
}
ul{
display: flex;
li{
position: relative;
flex:1; //水平分布
line-height: 1rem;
font-size: .875rem;
color: #ffeb7b;
text-align: center;
font-family: "electronicFont";
&:nth-child(1){ //给第一个li设置小竖线
&::after{
content:"";
position:absolute;
top: 25%;
height: 50%;
right: 0;
width: 1px;
background: rgba(255,255,255,0.2);
}
}
}
}
}
//文字模块
.no-bd{
ul{
display: flex;
li{
flex:1;
text-align: center;
color: rgba(255,255,255,0.7);
font-size: .225rem;
height: .5rem;
line-height: .5rem;
padding-top: .125rem;
}
}
}
}
.map{
position: relative;
height: 10.125rem;
.map1{
width: 6.475rem;
height: 6.475rem;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%); //保持水平居中,垂直居中
background: url(../images/map.png);
background-size: 100% 100%; //保证一起缩放
opacity: .3; //透明度
}
.map2{
position: absolute;
top:50%;
left: 50%;
transform: translate(-50%,-50%);
width: 8.0375rem;
height: 8.0375rem;
background: url(../images/lbx.png);
background-size: 100% 100%; //保证一起缩放
animation: rotate1 15s linear infinite; // 调用旋转
opacity: .6;
}
@keyframes rotate1 { //定义旋转动画
from{
transform: translate(-50%,-50%) //保留原来位置
rotate(0deg);
}
to{
transform: translate(-50%,-50%)
rotate(360deg);
}
}
.map3{
position: absolute;
top:50%;
left: 50%;
transform: translate(-50%,-50%);
width: 7.075rem;
height: 7.075rem;
background: url(../images/jt.png);
background-size: 100% 100%; //保证一起缩放
animation: rotate2 10s linear infinite; // 调用旋转
opacity: .6;
}
@keyframes rotate2 { //定义旋转动画
from{
transform: translate(-50%,-50%) //保留原来位置
rotate(0deg);
}
to{
transform: translate(-50%,-50%)
rotate(-360deg); //逆时针
}
}
.chart{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 10.125rem;
}
}