Skip to content

Commit 7ec6bb9

Browse files
committed
Refine answer spoiler style
1 parent e402587 commit 7ec6bb9

2 files changed

Lines changed: 71 additions & 4 deletions

File tree

src/main/resources/static/style.css

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ body {
88
flex-direction: column;
99
min-height: 100vh;
1010
margin: 0;
11+
font-size: 1.25rem; /* enlarge text */
1112
}
1213

1314
@media (prefers-color-scheme: dark) {
@@ -20,6 +21,18 @@ h1, h2, p {
2021
margin: 0.5em 0;
2122
}
2223

24+
h1 {
25+
font-size: 2em;
26+
font-weight: 700;
27+
margin-bottom: 0.75em;
28+
}
29+
30+
h2 {
31+
font-size: 1.5em;
32+
font-weight: 600;
33+
margin-bottom: 0.5em;
34+
}
35+
2336
ul { list-style: none; padding: 0; }
2437
summary {
2538
cursor: pointer;
@@ -31,7 +44,7 @@ details[open] summary::after {
3144
}
3245
main {
3346
width: 100%;
34-
max-width: 42rem;
47+
max-width: 52.5rem; /* wider center */
3548
margin: 0 auto;
3649
padding: 1rem;
3750
text-align: left;
@@ -40,3 +53,57 @@ main {
4053
from { opacity: 0; }
4154
to { opacity: 1; }
4255
}
56+
57+
button.btn {
58+
padding-top: 0.25rem;
59+
padding-bottom: 0.25rem;
60+
font-weight: 700;
61+
font-size: 1.05rem;
62+
}
63+
64+
.question {
65+
margin-bottom: 1rem;
66+
}
67+
68+
details.answer-container {
69+
margin-top: 1rem;
70+
}
71+
72+
details.answer-container summary {
73+
background-color: #eff6ff;
74+
padding: 0.5rem 1rem;
75+
border-radius: 0.375rem;
76+
border: 1px solid #bfdbfe;
77+
color: #1e40af;
78+
font-size: 1.1em;
79+
font-weight: 600;
80+
transition: background-color 0.3s, color 0.3s;
81+
position: relative;
82+
}
83+
84+
details.answer-container summary:hover {
85+
background-color: #dbeafe;
86+
}
87+
88+
details.answer-container summary::after {
89+
content: "\25BC";
90+
position: absolute;
91+
right: 0.75rem;
92+
transition: transform 0.3s ease;
93+
}
94+
95+
details.answer-container.open summary::after {
96+
transform: rotate(180deg);
97+
}
98+
99+
details.answer-container .answer {
100+
max-height: 0;
101+
overflow: hidden;
102+
opacity: 0;
103+
transition: max-height 0.5s ease, opacity 0.5s ease;
104+
}
105+
106+
details.answer-container.open .answer {
107+
max-height: 100vh;
108+
opacity: 1;
109+
}

src/main/resources/templates/question.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
<h1 th:text="'Категории: ' + ${#strings.listJoin(categories, ', ')}"></h1>
1616
<div th:if="${qa != null}">
1717
<h2 th:text="${qa.category}"></h2>
18-
<div class="markdown-body" th:utext="${qa.question}"></div>
19-
<details>
18+
<div class="question markdown-body" th:utext="${qa.question}"></div>
19+
<details class="answer-container">
2020
<summary>Ответ</summary>
21-
<div class="markdown-body" th:utext="${qa.answer}"></div>
21+
<div class="answer markdown-body" th:utext="${qa.answer}"></div>
2222
</details>
2323
</div>
2424
<div th:if="${qa == null}">

0 commit comments

Comments
 (0)