完成该项目需要具备以下知识:
安装easy less插件,使得可以编译less文件。在css文件夹下创建less文件就可以自动生成css文件
安装cssrem插件
设计稿是1920px
flexible.js 把屏幕分为 24 等份
cssrem 插件的基准值是 80px
插件-配置按钮—配置扩展设置–Root Font Size 里面 设置。
但是别忘记重启vscode软件保证生效
//css初始化
* {
margin: 0;
padding: 0;
box-sizing: 0;
}
body{
background: url(../images/bg.jpg);
line-height: 1.15;
}
index.less:
//css初始化
* {
margin: 0;
padding: 0;
box-sizing: 0;
}
body{
background: url(../images/bg.jpg) no-repeat top center;
line-height: 1.15;
}
header {
position: relative;
height: 1.25rem;
background: url(../images/head_bg.png) no-repeat top center;
background-size: 100% 100%;
h1 {
font-size: 0.475rem;
color: #fff;
text-align: center;
line-height: 1rem;
}
.showTime {
position: absolute;
top: 0;
right: 0.375rem;
line-height: 0.9375rem;
font-size: 0.25rem;
color: rgba(255, 255, 255, 0.7);
}
}
index.html:
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>数据可视化title>
<link rel="stylesheet" href="./css/index.css">
head>
<body>
<header>
<h1>Echarts数据可视化h1>
<div class="showTime">当前时间:2020年3月17-0时54分14秒div>
<script src="./js/showtime.js">script>
header>
<script src="./js/flexible.js">script>
body>
html>

需要一个上左右的10px 的内边距
column 列容器,分三列,占比 3:5:3
css样式:
.mainbox {
padding: 0.125rem 0.125rem 0;
display: flex;
.column {
flex: 3;
}
&:nth-child(2) {
flex: 5;
}
}
::before与::after
CSS 中,::before 创建一个伪元素,其将成为匹配选中的元素的第一个子元素。常通过 content 属性来为一个元素添加修饰性的内容。此元素默认为行内元素。
例子:
q::before {
content: "«";
color: blue;
}
q::after {
content: "»";
color: red;
}
结果图:

panel:
.panel {
position: relative;
height: 3.875rem;
border: 1px solid rgba(25, 186, 139, 0.17);
background: url(../images/line\(1\).png);
padding: 0 0.1875rem 0.5rem;
margin-bottom: 0.1875rem;
// 左上角
&::before {
position: absolute;
top: 0;
left: 0;
content: "";
width: 10px;
height: 10px;
border-top: 2px solid #02a6b5;
border-left: 2px solid #02a6b5;
}
// 右上角
&::after {
position: absolute;
top: 0;
right: 0;
content: "";
width: 10px;
height: 10px;
border-top: 2px solid #02a6b5;
border-right: 2px solid #02a6b5;
}
// 左下角和右下角
.panel-footer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
&::before {
position: absolute;
bottom: 0;
left: 0;
content: "";
width: 10px;
height: 10px;
border-bottom: 2px solid #02a6b5;
border-left: 2px solid #02a6b5;
}
&::after {
position: absolute;
bottom: 0;
right: 0;
content: "";
width: 10px;
height: 10px;
border-bottom: 2px solid #02a6b5;
border-right: 2px solid #02a6b5;
}
}
}
标题模块 h2 高度为 48px 文字颜色为白色 文字大小为 20px
图标内容模块 chart 高度 240px
以上可以作为panel公共样式部分
h2 {
height: 0.6rem;
line-height: 0.6rem;
text-align: center;
color: #fff;
font-size: 20px;
font-weight: 400;
}
.chart {
height: 3rem;
background-color: pink;
}

地图模块制作:
