Skip to content

Instantly share code, notes, and snippets.

@tonytins
Last active November 22, 2024 01:38
Show Gist options
  • Save tonytins/ef62f11a08966066fc72eac416aff4a1 to your computer and use it in GitHub Desktop.
Save tonytins/ef62f11a08966066fc72eac416aff4a1 to your computer and use it in GitHub Desktop.
Standard eBooks CSS
@charset "utf-8";
@namespace epub "http://www.idpf.org/2007/ops";
body {
font-variant-numeric: oldstyle-nums;
hyphens: auto;
-epub-hyphens: auto;
text-wrap: pretty;
}
p {
margin: 0;
text-indent: 1em;
}
hr {
border: none;
border-top: 1px solid;
height: 0;
margin: 1.5em auto;
width: 25%;
}
q::before,
q::after {
content: "";
}
blockquote {
margin: 1em 2.5em;
}
h1,
h2,
h3,
h4,
h5,
h6,
hgroup {
break-after: avoid;
break-inside: avoid;
font-variant: small-caps;
hyphens: none;
-epub-hyphens: none;
margin: 3em 0;
text-align: center;
}
/* simulate h3 in an hgroup */
hgroup h2 + p {
font-size: 1.17em;
}
/* simulate h4 in an hgroup */
hgroup h2 + p + p,
hgroup h3 + p {
font-size: 1em;
}
/* simulate h5 in an hgroup */
hgroup h2 + p + p + p,
hgroup h3 + p + p,
hgroup h4 + p {
font-size: 0.83em;
}
/* simulate h6 in an hgroup */
hgroup h2 + p + p + p + p,
hgroup h3 + p + p + p,
hgroup h4 + p + p,
hgroup h5 + p {
font-size: 0.67em;
}
hgroup > * {
font-weight: normal;
margin: 0;
}
hgroup > *:first-child {
font-weight: bold;
}
hgroup > p {
text-indent: 0;
}
p.continued,
h2 + p,
h3 + p,
h4 + p,
h5 + p,
h6 + p,
header + p,
hr + p,
hgroup + p,
p:first-child {
hanging-punctuation: first last;
text-indent: 0;
}
cite {
font-style: normal;
}
abbr {
border: none;
white-space: nowrap;
}
blockquote cite {
display: block;
font-style: italic;
text-align: right;
}
blockquote cite i {
font-style: normal;
}
b,
strong {
font-variant: small-caps;
font-weight: normal;
}
i > i,
em > i,
i > em {
font-style: normal;
}
ol,
ul {
margin-bottom: 1em;
margin-top: 1em;
}
header {
break-after: avoid;
break-inside: avoid;
hyphens: none;
-epub-hyphens: none;
text-align: center;
}
header > * + p {
text-indent: 0;
}
article > header + *,
section > header + * {
margin-top: 3em;
}
a[epub|type~="noteref"] {
font-size: 0.75em;
font-style: normal !important;
vertical-align: super;
}
section[epub|type~="endnotes"] > ol > li {
margin: 1em 0;
}
/* This may appear in the colophon */
abbr[epub|type~="se:era"] {
font-variant: all-small-caps;
}
section[epub|type~="titlepage"] h1,
section[epub|type~="titlepage"] p,
section[epub|type~="colophon"] h2,
section[epub|type~="imprint"] h2 {
left: -999em;
position: absolute;
}
section[epub|type~="titlepage"] img {
display: block;
margin: 3em auto auto auto;
width: 100%;
}
section[epub|type~="colophon"],
section[epub|type~="imprint"] {
text-align: center;
}
section[epub|type~="colophon"] header,
section[epub|type~="imprint"] header {
line-height: 0;
margin-top: 3em;
}
img[epub|type~="z3998:publisher-logo"] {
max-width: 25%;
width: 220px;
}
section[epub|type~="colophon"] p,
section[epub|type~="imprint"] p {
margin: 1em auto 0 auto;
text-indent: 0;
}
section[epub|type~="imprint"] p {
font-size: 0.75em;
text-align: justify;
width: 75%;
}
section[epub|type~="colophon"] p + p::before {
border-top: 1px solid;
content: "";
display: block;
margin: auto auto 1em auto;
width: 25%;
}
section[epub|type~="colophon"] a {
font-variant: small-caps;
}
section[epub|type~="imprint"] a,
section[epub|type~="colophon"] a {
hyphens: none;
-epub-hyphens: none;
}
section[epub|type~="copyright-page"] p {
margin: 1em auto;
text-indent: 0;
}
section[epub|type~="copyright-page"] blockquote p {
font-style: italic;
text-align: initial;
text-indent: 0;
}
section[epub|type~="copyright-page"] blockquote p span {
display: block;
padding-left: 1em;
text-indent: -1em;
}
section[epub|type~="copyright-page"] blockquote br {
display: none;
}
/* Invert images in dark mode. RMSDK requires a target media as well as a state. */
@media all and (prefers-color-scheme: dark) {
img[epub|type~="se:image.color-depth.black-on-transparent"] {
filter: invert(100%);
}
img[epub|type~="se:image.color-depth.black-on-transparent"][epub|type~="se:image.style.realistic"] {
background: currentColor;
filter: none;
}
}
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment