feat(screen): 添加响应式Mixin以适应屏幕

添加SCSS和Less的Mixin,根据设计稿尺寸(宽度1920px,高度982px)将px单位转换为vw/vh单位。包含用于宽度、高度和字体大小转换的函数,以确保响应式设计。将SCSS的Mixin导入主样式索引。
This commit is contained in:
Zzc 2025-10-31 20:19:04 +08:00
parent bfbbbfd228
commit cf620dc8c9
3 changed files with 51 additions and 0 deletions

View File

@ -1,3 +1,5 @@
@import './mixins.scss';
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;

View File

@ -0,0 +1,27 @@
// 屏幕适配工具 (Less 版本)
// 设计稿基准1920px (宽) × 982px (高,不含头部)
// 设计稿基准值
@design-width: 1920;
@design-height: 982;
// 将 px 转换为 vw (基于设计稿宽度 1920px)
.vw(@px) {
@vw-value: (@px / @design-width * 100vw);
}
// 将 px 转换为 vh (基于设计稿内容区域高度 982px)
.vh(@px) {
@vh-value: (@px / @design-height * 100vh);
}
// 字体大小转换 (使用 vw 确保响应式)
.fs(@px) {
@fs-value: (@px / @design-width * 100vw);
}
// 由于 Less 的限制,直接使用 calc() 表达式更简单
// 使用示例(推荐方式):
// width: calc(580 / 1920 * 100vw);
// height: calc(400 / 982 * 100vh);
// font-size: calc(16 / 1920 * 100vw);

View File

@ -0,0 +1,22 @@
// 屏幕适配工具
// 设计稿基准1920px () × 982px (不含头部)
// px 转换为 vw (基于设计稿宽度 1920px)
@function vw($px) {
@return calc($px / 1920 * 100vw);
}
// px 转换为 vh (基于设计稿内容区域高度 982px)
@function vh($px) {
@return calc($px / 982 * 100vh);
}
// 字体大小转换 (使用 vw 确保响应式)
@function fs($px) {
@return calc($px / 1920 * 100vw);
}
// 使用示例
// width: vw(580); // 580px vw
// height: vh(400); // 400px vh
// font-size: fs(16); // 16px vw