Flaurm界面优化

彩色横条手机端显示错位,影响页面布局

问题描述

原彩色横条在PC端显示正常,但手机端显示错位,如图所示:

image-20231228150431160

原代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
/* 首页顶部条 */
.IndexPage-toolbar::after {
content: "唯愿公平如大水滚滚 | 使公义如江河滔滔";
padding: 10px;
color: #ffffff;
border-radius: 50px;
text-align: center;
font-size: 16px;
background: linear-gradient(135deg, #29c7ac, #6699ff);
display: block;
margin: 5px 0;
}

解决方案

请备份所有数据再进行操作,此操作可能会导致网站不可用!

  • 为了让彩色条在手机显示时隐藏,使用CSS的媒体查询(Media Query)。媒体查询允许您根据不同的屏幕尺寸应用不同的样式规则。通常,手机屏幕的宽度小于768像素。因此,添加一个媒体查询来隐藏彩色条,当屏幕宽度小于768像素时。
  • 在下述这段代码中,.IndexPage-toolbar::after 的样式在屏幕宽度大于768像素时保持不变。但是,当屏幕宽度小于或等于768像素时(即在手机屏幕上),.IndexPage-toolbar::afterdisplay 属性被设置为 none,这意味着这个元素将会被隐藏。
  • 可以根据需要调整媒体查询中的 max-width 值以适应不同尺寸的手机屏幕。

更新后代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* 首页顶部条 */
.IndexPage-toolbar::after {
content: "唯愿公平如大水滚滚 | 使公义如江河滔滔";
padding: 10px;
color: #ffffff;
border-radius: 50px;
text-align: center;
font-size: 16px;
background: linear-gradient(135deg, #29c7ac, #6699ff);
display: block;
margin: 5px 0;
}

/* 在手机屏幕上隐藏顶部彩色条 */
@media (max-width: 768px) {
.IndexPage-toolbar::after {
display: none;
}
}

表格布局美化

问题描述

原表格样式间距太大,手机端无法适配。

解决方案

请备份所有数据再进行操作,此操作可能会导致网站不可用!

  • 固定布局:列宽固定,不随内容自动调整。
  • 内容断行:允许内容在单元格内断行,防止溢出。
  • 边框样式:单元格边框统一,颜色一致。
  • 隔行变色:表格的每个偶数行和表头背景色设置为浅灰色,增强可读性。
  • 表头加粗:表头文字加粗,突出显示。
  • 内外边距调整:优化表格和单元格的内外边距,使布局更加紧凑。

更新后代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* 表格美化 */
table {
table-layout:fixed;
padding: 0;
word-break: break-all;
border-collapse: collapse;
margin: 0.8em 0;
width: 100%;
}
table tr {
border: 1px solid #dfe2e5;
margin: 0;
padding: 0;
}
table tr:nth-child(2n), thead {
background-color: #f8f8f8;
}
table th {
font-weight: bold;
border: 1px solid #dfe2e5;
border-bottom: 0;
margin: 0;
padding: 6px 13px;
width: auto ! important;
}
table td {
border: 1px solid #dfe2e5;
margin: 0;
padding: 6px 13px;
}
table th:first-child, table td:first-child {
margin-top: 0;
}
table th:last-child, table td:last-child {
margin-bottom: 0;
}

字体美化

问题描述

  • 需要更换字体
  • 需要保证字体可以适配全部设备
  • 在调试时部分设备字体出现乱码情况

如图所示:

image-20231228152034896

解决方案

请备份所有数据再进行操作,此操作可能会导致网站不可用!

  • 先添加js代码:打开 Flarum 「管理后台」,在 「外观」的 「自定义页眉」(Custom Header)加入如下代码:
1
<link href="https://cdn.staticfile.org/lxgw-wenkai-screen-webfont/1.7.0/lxgwwenkaiscreen.css" rel="stylesheet">
  • 在「自定义样式CSS」 (Custom Styles)加入如下代码:

这里基本适配所有的终端设备字体,请根据自己的需求进行修改。

1
2
3
4
5
6
7
8
/* 字体美化 - 添加苹果设备字体和通用备选字体 */
body {
font-family: 'LXGW WenKai Screen', 'Times New Roman', 'Times', 'Georgia', serif;
}

h1, h2, h3, h4, .TagsLabel, .Button, .DiscussionListItem-count, .item-discussion-views {
font-family: 'LXGW WenKai Screen', 'Arial', 'Helvetica Neue', 'San Francisco', sans-serif;
}

取消欢迎关闭按钮

解决方案

请备份所有数据再进行操作,此操作可能会导致网站不可用!

1
2
3
4
/* 取消欢迎关闭按钮 */
.Hero-close{
display:none;
}

字体美化

问题描述

  • 昵称过长、Link数量过多等原因导致搜索框错位,影响观感。

如图所示:

image-20231228155706852

解决方案

请备份所有数据再进行操作,此操作可能会导致网站不可用!

  • 在「自定义样式CSS」 (Custom Styles)加入如下代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@media (min-width: 768px) and (max-width: 1099px) {
.Header-primary .Header-controls {
max-width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.Header-primary:after {
content: " > ";
margin-left: 20px;
}

.Header-primary:hover {
padding-right: 30px;
padding-bottom: 20px;
}
.Header-primary:hover .Header-controls {
transition: max-width 1s;
max-width: 1000px;
overflow: unset;
animation: delay-overflow-unset 1s;
}
@keyframes delay-overflow-unset {
from {
overflow: hidden;
}
to {
overflow: unset;
}
}
.Header-primary:hover:after {
content: "";
}

.Header-primary:hover + .Header-secondary {
white-space: nowrap;
overflow: hidden;
margin-right: 20px;
float: unset;
}
}

.Header-secondary .item-session button {
max-width: 140px;
overflow: hidden;
text-overflow: ellipsis;
}