From 1566a795ebcb4382858fbf607b3a7f353a86905b Mon Sep 17 00:00:00 2001 From: mxr612 Date: Wed, 5 Mar 2025 03:34:45 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86CSS=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 1 + static/styles.css | 102 ++++++++++++++++++++++++++++++++++++++++++ templates/index.html | 6 ++- templates/result.html | 1 + templates/scale.html | 44 ++++++------------ 5 files changed, 122 insertions(+), 32 deletions(-) create mode 100644 static/styles.css diff --git a/app.py b/app.py index cc92e44..6bd30cb 100644 --- a/app.py +++ b/app.py @@ -9,6 +9,7 @@ import uvicorn app = FastAPI() templates = Jinja2Templates(directory="templates") +app.mount("/static", StaticFiles(directory="static"), name="static") # 加载所有问卷数据 def load_all_scales(): diff --git a/static/styles.css b/static/styles.css new file mode 100644 index 0000000..4c92bac --- /dev/null +++ b/static/styles.css @@ -0,0 +1,102 @@ +/* 全局样式 */ +body { + font-family: Arial, sans-serif; + line-height: 1.6; + margin: 0; + padding: 0; + + width: 40%; + max-width: 1200px; + margin: 0 auto; + + /* 可选:添加一些内边距,让内容不紧贴容器边缘 */ + padding: 20px; + + /* 设置背景颜色为纯白色 */ + background-color: #ffffff; + color: #333; +} + +@media (max-width: 768px) { + body { + width: 100%; + /* 全屏展示 */ + padding: 10px; + /* 适当调整内边距 */ + } +} + +/* 容器样式 */ +.container { + width: 40%; + max-width: 1200px; + margin: 0 auto; + + /* 可选:添加一些内边距,让内容不紧贴容器边缘 */ + padding: 20px; +} + +/* 标题样式 */ +h1, +h2, +h3 { + color: #444; +} + +/* 链接样式 */ +a { + color: #007BFF; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +/* 表单样式 */ +form { + background-color: #fff; + padding: 20px; + border-radius: 5px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +/* 按钮样式 */ +button { + background-color: #007BFF; + color: #fff; + padding: 10px 20px; + border: none; + border-radius: 5px; + cursor: pointer; +} + +button:hover { + background-color: #0056b3; +} + +/* 定义单选按钮容器样式 */ +.radio-button-group { + display: flex; + gap: 10px; + /* 按钮之间的间距 */ +} + +/* 定义单选按钮隐藏样式 */ +.radio-button-group input[type="radio"] { + display: none; +} + +/* 定义单选按钮标签样式 */ +.radio-button-group label { + padding: 10px 20px; + border: 1px solid #ccc; + border-radius: 5px; + cursor: pointer; +} + +/* 定义单选按钮选中时标签样式 */ +.radio-button-group input[type="radio"]:checked+label { + background-color: #007BFF; + color: white; +} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 783d553..ea9586e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,10 +1,13 @@ + 心尺 PsychoScales + + {% if readme_content %}
@@ -13,8 +16,9 @@ {% endif %} + \ No newline at end of file diff --git a/templates/result.html b/templates/result.html index 9b7160c..3b0d1dd 100644 --- a/templates/result.html +++ b/templates/result.html @@ -4,6 +4,7 @@ Result +

{{ scale_title }}

diff --git a/templates/scale.html b/templates/scale.html index 32f13bc..7dddb45 100644 --- a/templates/scale.html +++ b/templates/scale.html @@ -1,48 +1,30 @@ + {{ scale.title }} - + +

{{ scale.title }}

{{ scale.instructions }}

{% for question in scale.questions %} - -
- - {% for option in range(question.range[0], question.range[1]+1) %} - - - {% endfor %} -
+ +
+ + {% for option in range(question.range[0], question.range[1]+1) %} + + + {% endfor %} +
{% endfor %}
+ \ No newline at end of file