This is an exercise in simplicity and clarity: cutting down extraneous fluff to make sure the content stands out clearly. It has also been an excellent way to learn a little more about .css
.
The stylesheet is designed to be used for blog posts, mainly, but has features one needs for a more interactive site too.
It comes in dark and light modes:
It has only one class, .center
, which is used to...
π― ...center π―
any
element.
It modestly styles input and textareas:
Hello there!
It can handle images nicely, scaling to the screen.
And it renders blockquotes sensibly, in the serifed Wikipedia style.
And though she be but little, she is fierce!
-- HELENA, Act 2 Scene 2
Tables can be a bit plain, but they mostly work:
Country | Capital | Flag |
---|---|---|
Zimbabwe | Harare | πΏπΌ |
Zambia | Lusaka | πΏπ² |
Credit to Joey Burzynski's 58 bytes of CSS for inspiring this particular exercise.
Here is the full code, de-minified. Feel free to use and adapt!
/*The 1kb stylesheet*/
:root {
--b: #fffce4;
--t: #161b2b;
--a: #51518a;
--s: #80808034;
}
@media (prefers-color-scheme: dark) {
:root{
--t: #fffce4;
--b: #161b2b;
--a: #a2a2e7;
}}
:root{
font: 13pt sans-serif;
line-height: 1.3;
background:var(--b);
color: var(--t);
max-width: 80ch;
padding: 0.6em;
margin: auto;
}
h1,h2,h3{
font-family: serif;
margin: 1.4em 0 0.1em;
}
button,pre,img,input,textarea {
border-radius: 0.5rem;
padding: 0.4rem;
}
img{
max-height: 40vh;
max-width: 95%;
}
img, .center{
display: block;
text-align: center;
margin:auto;
}
a:hover,button:hover{
filter:brightness(130%);
cursor:pointer;
}
a{
color: var(--a);
}
button{
background:var(--t);
color:var(--b);
font-size: 1em;
}
input,textarea{
background: var(--s);
font-size: 1em;
color: var(--t);
border: 2px solid var(--t);
margin-right: -0.7em;
padding-right: 1em;
}
small, sup {
font-size: 0.6em;
}
pre{
background:#222;
color: #fff;
overflow-x: scroll;
border: 2px solid #fff;
}
blockquote, p code,table{
background: var(--s);
padding:0.2em;
}
blockquote{
border-left: 3pt solid;
padding: 1px 0.3em 1px 1em ;
font-family: serif;
}
table {
text-align: center;
margin: auto;
}
td {
padding:0.35rem;
background: var(--b);
}
*everywhere == my entirely subjective use-case