div+css实现响应式自适应简洁数据仪表盘代码

代码语言:html

所属分类:响应式

代码描述:div+css实现响应式自适应简洁数据仪表盘代码

代码标签: div css 响应式 自适应 简洁 数据 仪表盘 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  
 <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cute+Font&family=Oxanium&display=swap" rel="stylesheet">
  
<style>
* {
  margin: 0;
  padding: 0;
  font: inherit;
  box-sizing: border-box;
}

body {
  background: #000;
  color: #fff;
  font-family: 'Oxanium', sans-serif;
  font-size: 100%;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

h2 {
  color:#000;
  font-size: 1.65em;
  line-height:1.1;
}

.profile h2 {
  font-size: 2em;
}

h2,
p,
th {
  font-family: 'Cute Font', sans-serif;
  text-transform: uppercase;
}

h2,
p,
table {
  text-align: center;
}

p,th{
  font-size: 1.3em;
}

th{
	color:#02bd27;
	background-color:#000;
}

td,
li,
.calories div {
  font-size: 0.9em;
}

tr:nth-child(odd)
{
  background-color: rgba(0,0,0,0.5);
}

tr:nth-child(even) {
  background-color: rgba(0,0,0,0.7);
}

table,
tr,
th,
td {
  border: none;
}

table {
  width: 100%;
}

th,
td {
  padding: 0.3em 0.75em;
}

ul {
  list-style: none;
}

li {
  margin: 0.25em auto;
}

li,
.calories div {
  padding: 0.25em 0.5em;
}

.dashboard {
  background:#113017;
background-image: repeating-linear-gradient(
		to bottom,
		#113017 5%,
		#08240d 6%
	);
  max-width: 80%;
  margin: 2.5% auto; 
  padding: 2.5%;
  border: 0.75em double #000;
  border-radius: 1em;
  box-shadow: 0.2em 0.2em 0em #08240d;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  justify-items: stretch;
  align-items: center;
  gap: 1em;
}

.box {
  background-color: #214702;
  padding: 1em 0.75em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  border: 0.2em solid #000;
  border-radius: 0.5em;
  box-shadow: 0em 0em 0.5em #000;
}

.box:hover {
	background-color: #1e3d04;
	border: 0.2em solid #02bd27;
}

.box:hover > h2 {
  color:#02bd27;
}

.profile {
  grid-column: 1/2;
  grid-row: 1/2;
  align-self: flex-end;
}

.profile > h2,
.profile > p{
  color:#d4d00d;
}

.schedule-table {
  grid-column: 3/-1;
  grid-row: 1/3;
  align-self: flex-end;
}

.exercise-table {
  grid-column: 1/2;
  grid-row: 2/4;
}

.calories {
  grid-column: 2/3;
  grid-row: 3/4;
}

.personal-bests {
  grid-column: 2/3;
  grid-row: 1/2;
}

.challenges {
  grid-column: 2/3;
  grid-row: 2/3;
}

.activity-feed {
  grid-column: 3/-1;
  grid-row: 3/5;
  align-self: flex-start;
}

.activity-feed > h2{
  color:#d4d00d;
}

.activity-feed > ul{
  color:#02bd27;
}

.activity-feed, .profile{
	background-color:#000;
	border: 0.2em solid #02bd27;
}

.activity-feed:hover, .profile:hover{
	background-color:#000;
}

@media (max-width: 1300px) {
  body {
    font-size: 95%;
  }
}

@media (max-width: 1200px) {
  .dashboard {
    max-width: 90%;
  }
}

@media (max-width: 1100px) {
  body {
    font-size: 90%;
  }
}

@media (max-width: 1000px) {
  .dashboard {
    grid-template-columns: repeat(3, 1fr);
  }

  .profile {
    grid-column: 1/2;
    grid-row: 1/2;
  }

  .schedule-table {
    grid-column: 2/-1;
    grid-row: 1/3;
  }

  .exercise-table {
    grid-column: 1/2;
    grid-row: 2/4;
  }

  .calories {
    grid-column: 2/3;
    grid-row: 3/4;
  }

  .personal-bests {
    grid-column: 1/2;
    grid-row: 4/5;
  }

  .challenges {
    grid-column: 3/-1;
    grid-row: 3/4;
  }

  .activity-feed {
    grid-column: 2/-1;
    grid-row: 4/5;
  }
}

@media (max-width: 750px) {
  .dashboard {
    width: 98%;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5em;
  }

  .profile {
    grid-column: 1/2;
    grid-row: 1/2;
  }

  .schedule-table {
    grid-column: 1/-1;
    grid-row: 3/4;
  }

  .exercise-table.........完整代码请登录后点击上方下载按钮下载查看

网友评论0