构建一个静态html页面 页面是小圆点组成七个正六边形,,每个正六边形有个高亮的小圆点会动态围着六边形边框亮;页面缩小会随之缩小适应1920-2560分辨率
时间: 2023-06-12 21:08:03 浏览: 62
以下是一个实现该需求的静态 HTML 页面代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>七个正六边形页面</title>
<style>
/* 设置页面背景色和字体颜色 */
body {
background-color: #f0f0f0;
color: #333;
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
/* 设置正六边形容器的样式 */
.hexagon-container {
width: 100%;
height: 100vh;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
position: relative;
box-sizing: border-box;
}
@media screen and (max-width: 2560px) {
.hexagon-container {
max-width: 2560px;
}
}
@media screen and (max-width: 1920px) {
.hexagon-container {
max-width: 1920px;
}
}
/* 设置单个正六边形的样式 */
.hexagon {
width: 25%;
height: 50%;
position: relative;
overflow: hidden;
margin: 0;
padding: 0;
box-sizing: border-box;
transform: rotate(30deg);
}
@media screen and (max-width: 1500px) {
.hexagon {
width: 33.33%;
}
}
@media screen and (max-width: 1200px) {
.hexagon {
width: 50%;
}
}
@media screen and (max-width: 768px) {
.hexagon {
width: 100%;
}
}
/* 设置正六边形边框和背景颜色 */
.hexagon:before {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: rotate(-30deg);
background-color: #fff;
border: 1px solid #ccc;
box-sizing: border-box;
}
/* 设置高亮小圆点的样式 */
.hexagon:after {
content: "";
display: block;
position: absolute;
top: -10px;
left: calc(50% - 10px);
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #ffcc00;
box-shadow: 0 0 10px #ffcc00;
animation: circle 2s infinite linear;
box-sizing: border-box;
}
/* 设置高亮小圆点的动画 */
@keyframes circle {
0% {
transform: translateX(0) rotate(0);
}
100% {
transform: translateX(100%) rotate(360deg);
}
}
</style>
</head>
<body>
<div class="hexagon-container">
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
</div>
</body>
</html>
```
在该代码中,我们将页面的背景色设置为浅灰色,字体颜色设置为深灰色。然后,我们创建了一个名为 `hexagon-container` 的容器,用于容纳七个正六边形。该容器使用了 `flex` 布局,并且设置了最大宽度以适应不同的分辨率。接着,我们定义了一个名为 `hexagon` 的 CSS 类,用于设置单个正六边形的样式。同时,我们使用了 `:before` 伪元素来设置正六边形的边框和背景色。最后,我们使用了 `:after` 伪元素来创建一个高亮小圆点,用于绕着正六边形边框闪烁。该小圆点使用了动画效果,并且在不同的分辨率下,正六边形的大小也会自动适应。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)