修复了公告栏文字未上下居中的问题

This commit is contained in:
2026-06-12 23:38:36 +08:00
parent 84be8489b4
commit 6691ebd85e
3 changed files with 55 additions and 57 deletions

0
1.py Normal file
View File

View File

@@ -4,13 +4,13 @@
background: linear-gradient(180deg, #f5faff 0%, #f0f8ff 100%); background: linear-gradient(180deg, #f5faff 0%, #f0f8ff 100%);
} }
/* ===== 2. 公告栏样式 - 物理上移方案 ===== */ /* ===== 2. 公告栏样式 ===== */
.gonggao-box { .gonggao-box {
margin: 20rpx 30rpx; margin: 20rpx 30rpx;
height: 80rpx; height: 80rpx;
border-radius: 40rpx; border-radius: 40rpx;
background: linear-gradient(135deg, background: linear-gradient(135deg,
rgba(220, 255, 220, 0.85) 0%, rgba(220, 255, 220, 0.85) 0%,
rgba(255, 255, 200, 0.85) 100%); rgba(255, 255, 200, 0.85) 100%);
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
display: flex; display: flex;
@@ -18,10 +18,9 @@
padding: 0 25rpx; padding: 0 25rpx;
box-shadow: 0 4rpx 15rpx rgba(0, 100, 0, 0.08); box-shadow: 0 4rpx 15rpx rgba(0, 100, 0, 0.08);
border: 1rpx solid rgba(255, 255, 255, 0.3); border: 1rpx solid rgba(255, 255, 255, 0.3);
position: relative;
overflow: hidden; overflow: hidden;
} }
.gonggao-icon { .gonggao-icon {
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
@@ -30,47 +29,33 @@
display: flex; display: flex;
align-items: center; align-items: center;
} }
.gonggao-icon image { .gonggao-icon image {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.gonggao-content { .gonggao-content {
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
height: 100%; height: 80rpx;
position: relative; display: flex;
margin-top: 2px; /* 视觉上的微小修正 */
} }
/* 关键修改:使用物理上移 */
.gonggao-text { .gonggao-text {
font-size: 26rpx; font-size: 26rpx;
color: #333; color: #333;
white-space: nowrap; white-space: nowrap;
padding-right: 50rpx; padding-right: 50rpx;
line-height: 1;
/* 物理上移方法1直接调整位置 */
position: absolute;
top: -5rpx; /* 从顶部开始计算位置 */
left: 0;
/* 或者使用方法2负margin上移 */
/* position: relative;
top: -10rpx; */
/* 或者使用方法3translate上移 */
/* transform: translateY(-5rpx); */
} }
/* 尝试不同的上移值,直到居中为止 */
/* 可以尝试的值5rpx, 8rpx, 10rpx, 12rpx, 15rpx, 18rpx, 20rpx */
.gonggao-anim { .gonggao-anim {
animation: marquee 10s linear infinite; /* 加快速度到10秒 */ animation: marquee 10s linear infinite;
animation-delay: 0.5s; animation-delay: 0.5s;
} }
@keyframes marquee { @keyframes marquee {
0% { 0% {
transform: translateX(100%); transform: translateX(100%);

View File

@@ -1,29 +1,42 @@
{ {
"compileType": "miniprogram", "compileType": "miniprogram",
"setting": { "setting": {
"coverView": true, "coverView": true,
"es6": true, "es6": true,
"postcss": true, "postcss": true,
"minified": true, "minified": true,
"enhance": true, "enhance": true,
"showShadowRootInWxmlPanel": true, "showShadowRootInWxmlPanel": true,
"packNpmRelationList": [], "packNpmRelationList": [],
"babelSetting": { "babelSetting": {
"ignore": [], "ignore": [],
"disablePlugins": [], "disablePlugins": [],
"outputPath": "" "outputPath": ""
}, },
"ignoreUploadUnusedFiles": true "ignoreUploadUnusedFiles": true,
}, "compileWorklet": false,
"condition": {}, "uglifyFileName": false,
"editorSetting": { "uploadWithSourceMap": true,
"tabIndent": "insertSpaces", "packNpmManually": false,
"tabSize": 4 "minifyWXSS": true,
}, "minifyWXML": true,
"libVersion": "3.14.3", "localPlugins": false,
"packOptions": { "disableUseStrict": false,
"ignore": [], "useCompilerPlugins": false,
"include": [] "condition": false,
}, "swc": false,
"appid": "wx0e4be86faac4a8d1" "disableSWC": true
},
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 4
},
"libVersion": "3.14.3",
"packOptions": {
"ignore": [],
"include": []
},
"appid": "wx0e4be86faac4a8d1",
"simulatorPluginLibVersion": {}
} }