/* 页面全局初始化与居中布局 */
body {
font-family: 'Segoe UI', Arial, sans-serif;
background-color: #f5f7fa;
margin: 0;
padding: 0;
display: block; /* 避免 WeasyPrint/低版本引擎兼容问题 */
}
.container {
background-color: #ffffff;
padding: 40px;
border-radius: 12px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
width: 85%;
max-width: 600px;
margin: 50px auto; /* 保证居中 */
}
h1 {
text-align: center;
margin-top: 0;
color: #2c3e50;
font-size: 20px;
}
label {
font-weight: bold;
display: block;
margin-bottom: 8px;
color: #34495e;
}
/* 输入框核心样式 */
textarea {
width: 100%;
padding: 12px;
border: 2px solid #e0e6ed;
border-radius: 8px;
font-size: 14px;
box-sizing: border-box;
}
textarea:focus {
border-color: #3498db;
outline: none;
}

Java课程设计:Web端文本统计器重构指南 3 / 7

3. 核心大智慧: js/app.js
用原生的 JavaScript 处理 DOM 交互与正则表达式统计逻辑:
/* 统计区域表格化/块状模拟两列布局 */
.stats-group {
margin-top: 20px;
width: 100%;
}
.stat-item {
width: 47%;
display: inline-block;
vertical-align: top;
}
.stat-item:last-child {
float: right;
}
input[type="text"] {
width: 100%;
padding: 12px;
background-color: #f8f9fc;
border: 1px solid #dcdfe6;
border-radius: 8px;
font-size: 16px;
font-weight: bold;
color: #e74c3c;
text-align: center;
box-sizing: border-box;
cursor: not-allowed;
}