欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 美食 > 蓝桥杯 - 简单 - 电影院排座位

蓝桥杯 - 简单 - 电影院排座位

2025/5/9 7:09:28 来源:https://blog.csdn.net/2302_81312344/article/details/146417615  浏览:    关键词:蓝桥杯 - 简单 - 电影院排座位

介绍

随着人们生活水平的日益提升,电影院成为了越来越多的人休闲娱乐,周末放松的好去处。各个城市的电影院数量也随着市场的需求逐年攀升。近日,又有一个电影院正在做着开张前期的准备,小蓝作为设计工程师,需要对电影院的座位进行布局设计。

本题需要在已提供的基础项目中,使用 CSS 达到对电影院排座位的目的。

准备

开始答题前,需要先打开本题的项目代码文件夹,目录结构如下:

├── css
│   └── style.css
└── index.html

其中:

  • index.html 是主页面。
  • css/style.css 是需要补充样式的文件。

注意:打开环境后发现缺少项目代码,请手动键入下述命令进行下载:

cd /home/project
wget https://labfile.oss.aliyuncs.com/courses/18213/02.zip && unzip 02.zip && rm 02.zip

在浏览器中预览 index.html,显示如下所示:

目标

请在 css/style.css 文件中的 TODO 下补全样式代码,最终达到预期布局效果,需要注意:

  • 座位区域和荧幕间隔 50px。
  • 座位区域每一行包含 8 个座位。
  • 第 2 列和第 6 列旁边都是走廊,需要和下一列间隔 30px,其他列都只需要间隔 10px。

完成后的效果如下:

规定

  • 请勿修改 css/style.css 文件外的任何内容。
  • 请严格按照考试步骤操作,切勿修改考试默认提供项目中的文件名称、文件夹路径、class 名、id 名、图片名等,以免造成无法判题通过。

代码


<!DOCTYPE html>
<html lang="zh-CN"><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/style.css" /></head><body><div class="container"><!-- 屏幕区域 --><div class="screen">阿凡达2</div><!-- 座位区域 --><div class="seat-area"><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div><div class="seat"></div></div></div></body>
</html>
* {box-sizing: border-box;
}body {background-color: #242333;color: #fff;display: flex;flex-direction: column;align-items: center;justify-content: center;height: 100vh;margin: 0;
}.container {perspective: 1000px;width: 470px;
}.screen {background-color: #fff;height: 70px;width: 100%;transform: rotateX(-45deg);box-shadow: 0 3px 10px rgba(255, 255, 255, 0.7);color: #242333;text-align: center;line-height: 70px;font-size: 30px;
}.seat {background-color: #444451;height: 40px;width: 45px;border-top-left-radius: 10px;border-top-right-radius: 10px;
}/* TODO:待补充代码 */
.seat-area {/* 座位区域和荧幕间隔 50px。 */margin-top: 50px;/* 定义flex布局 */display: flex;/* 定义方向 row  默认*/flex-direction: row;/* 定义换行 向下换行 */flex-wrap: wrap;/* border: 1px red solid; */
}
.seat{/* 全部座位 */margin-bottom: 10px;margin-right: 10px;
}
/* 第二列 和 第六列*/
.seat:nth-child(4n+2){margin-right: 30px;
}
.seat:nth-child(8n+8){/* 最后一列 */margin-right: 0;
}
.seat:nth-child(n+40){/* 最后一行 */margin-bottom: 0;
}

 知识补充

  • Flex 布局教程:语法篇 - 阮一峰的网络日志
  • CSS的新特性(选择器、盒子模型、过渡...)

总结

  • 可以通过边框来查看效果;
  • 可以通过F12查看盒子模型的值等;

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词