Skip to content

Commit fbdf2a3

Browse files
authored
Merge pull request #106 from ENCCS/selection-bg-color
Use a custom selection background and foreground color
2 parents d640423 + 8ecedb9 commit fbdf2a3

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

sphinx_lesson/_static/sphinx_lesson.css

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
/* sphinx_lesson.css */
1+
/* sphinx_lesson.css
2+
* https://webaim.org/resources/contrastchecker/?fcolor=00000&bcolor=FCE762
3+
* */
4+
:root {
5+
--sphinx-lesson-selection-bg-color: #fce762;
6+
--sphinx-lesson-selection-fg-color: #000000;
7+
}
8+
9+
/* https://webaim.org/resources/contrastchecker/?fcolor=FFFFFF&bcolor=745315
10+
* when dark theme is selected the some themes use this attirbute
11+
*/
12+
html[data-theme='dark'], body[data-theme='dark'] {
13+
--sphinx-lesson-selection-bg-color: #745315;
14+
--sphinx-lesson-selection-fg-color: #ffffff;
15+
}
16+
17+
/* when browser/system theme is dark and no theme is selected */
18+
@media (prefers-color-scheme: dark) {
19+
html[data-theme='auto'], body[data-theme='auto'] {
20+
--sphinx-lesson-selection-bg-color: #745315;
21+
--sphinx-lesson-selection-fg-color: #ffffff;
22+
}
23+
}
224

325
body.wy-body-for-nav img.with-border {
426
border: 2px solid;
@@ -49,3 +71,33 @@ body.wy-body-for-nav img.with-border {
4971
.rst-content .admonition.toggle-hidden {
5072
padding-bottom: 0px;
5173
}
74+
75+
/* selection / highlight colour uses a yellow background and a black text */
76+
/*** Works on common browsers ***/
77+
::selection {
78+
background-color: var(--sphinx-lesson-selection-bg-color);
79+
color: var(--sphinx-lesson-selection-fg-color);
80+
}
81+
82+
/*** Mozilla based browsers ***/
83+
::-moz-selection {
84+
background-color: var(--sphinx-lesson-selection-bg-color);
85+
color: var(--sphinx-lesson-selection-fg-color);
86+
}
87+
88+
/***For Other Browsers ***/
89+
::-o-selection {
90+
background-color: var(--sphinx-lesson-selection-bg-color);
91+
color: var(--sphinx-lesson-selection-fg-color);
92+
}
93+
94+
::-ms-selection {
95+
background-color: var(--sphinx-lesson-selection-bg-color);
96+
color: var(--sphinx-lesson-selection-fg-color);
97+
}
98+
99+
/*** For Webkit ***/
100+
::-webkit-selection {
101+
background-color: var(--sphinx-lesson-selection-bg-color);
102+
color: var(--sphinx-lesson-selection-fg-color);
103+
}

0 commit comments

Comments
 (0)