Stylesheet oskog97.com

This is the stylesheet I use for my pages.

  • It has mobile friendly a-elements (links).
  • It contains all the styling for the navigation bar.
  • It's printer friendly and mobile friendly.

See also: The script that generates the navigation bar and includes the footer in every page

Last modified
Lines 400

Parent directory Download CGIread sitemap Main page

Quick links: content footer navigation title

  1. /*
  2.  * Copyright © Oskar Skog, 2014-2021
  3.  * 
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions are met:
  6.  * 
  7.  * 1.  Redistributions of source code must retain the above copyright notice,
  8.  *     this list of conditions and the following disclaimer.
  9.  * 
  10.  * 2.  Redistributions in binary form must reproduce the above copyright notice,
  11.  *     this list of conditions and the following disclaimer in the documentation
  12.  *     and/or other materials provided with the distribution.
  13.  * 
  14.  * This software is provided by the copyright holders and contributors "as is"
  15.  * and any express or implied warranties, including, but not limited to, the
  16.  * implied warranties of merchantability and fitness for a particular purpose
  17.  * are disclaimed. In no event shall the copyright holder or contributors be
  18.  * liable for any direct, indirect, incidental, special, exemplary, or
  19.  * consequential damages (including, but not limited to, procurement of
  20.  * substitute goods or services; loss of use, data, or profits; or business
  21.  * interruption) however caused and on any theory of liability, whether in
  22.  * contract, strict liability, or tort (including negligence or otherwise)
  23.  * arising in any way out of the use of this software, even if advised of the
  24.  * possibility of such damage.
  25.  * 
  26.  * ****************************************************************************
  27.  * 
  28.  * 
  29.  * See https://oskog97.com/read.py?path=/mkhtml for the script used for
  30.  * generating my pages.
  31.  * 
  32.  * See https://oskog97.com/read.py?path=/template.html.src for the template
  33.  * I use.
  34.  * I cannot use it to generate a `blank page`, it's not in my site's
  35.  * navigation.
  36.  * 
  37.  * See any page and its input (URL+'.src') for examples.
  38.  * 
  39.  * 
  40.  * <!-- Navigation generated by ./mkhtml -->
  41.  * <div id="navigation">...</div>
  42.  * 
  43.  * <!-- First header generated by ./mkhtml -->
  44.  * <h1 id="title">baz -- Test page</h1>
  45.  * 
  46.  * <!-- Real content of page -->
  47.  * <div id="content"><!-- content --></div>
  48.  * 
  49.  * <!-- Footer *inserted* by ./mkhtml -->
  50.  * 
  51.  * Links on touchscreens need to be large.
  52.  * .a, a        add spacing
  53.  * .a a         add no spacing
  54.  * <span class="a">(<a href="foo.html">foo</a>)</span>
  55.  *      will not add extra spacing: (foo)
  56.  * (<a href="foo.html">foo</a>)
  57.  *      will add extra spacing: (  foo  )
  58.  * Ex. links in the end of a sentence are immediately followed
  59.  * by a period, which isn't in the link.
  60.  * 
  61.  * a.notprint   Do not print this link, not needed for navigation.
  62.  * a.printurl   Print the destination URL when printing
  63.  */
  64. /* ### GLOBAL LAYOUT ### */
  65. /*
  66.  * This will cause #content to be marginalized
  67.  * within a marginalized body.
  68.  */
  69. body {
  70.     overflow-wrap: break-word;
  71. }
  72. @media only screen and (min-width: 1024px)
  73. {
  74.     body {
  75.         margin-left: 2.5em;
  76.         margin-right: 2.5em;
  77.         margin-top: 0.5em;
  78.     }
  79.     #content {
  80.         margin-left: auto;
  81.         margin-right: auto;
  82.         max-width: 1024px; /* Notice that the surrounding <body> has margins. */
  83.     }    
  84. }
  85. @media only screen and (max-width: 1023px)
  86. {
  87.     body, #content
  88.     {
  89.         margin-left: 0.5em;
  90.         margin-right: 0.5em;
  91.         margin-top: 0.5em;
  92.     }
  93. }
  94. /* Sections and page breaking */
  95. .atom {
  96.     page-break-inside: avoid;
  97. }
  98. @media not print
  99. {
  100.     .section {
  101.         margin-top: 7em;
  102.     }
  103. }
  104. @media print
  105. {
  106.     .section, p, img, table, .atom {
  107.         page-break-inside: avoid;
  108.     }
  109.     h1, h2, h3, h4, h5, h6, dt {
  110.         display: block;
  111.         page-break-after: avoid;
  112.         break-after: avoid;
  113.     }
  114. }
  115. /*
  116.  * ### NAVIGATION ###
  117.  */
  118. /*
  119.  * White                    Not clickable
  120.  * Yellow                   Link
  121.  * Orange                   Visited link
  122.  * Blue                     Background
  123.  * 
  124.  * Rows are separated by a great line-height and
  125.  * thin, long, white borders.
  126.  * 
  127.  *          [head]
  128.  *          >>
  129.  *          [sub]
  130.  *
  131.  *  [head] >> [sub] [sub] [sub]         Root+children
  132.  *  [head] >> [sub] [sub]               Self+children/self+parent
  133.  *  >> [sub] [sub] [sub]                Subs (policy, contact, etc.)
  134.  * 
  135.  * head >bold> sub          (bolder-than)
  136.  * 
  137.  * [active] ]clickable[
  138.  * 
  139.  * Example of the code:
  140.  * <nav><div id="navigation"><div id="nav_inner">
  141.  * <p><a href="#content" class="textonly">Skip navigation</a></p>
  142.  * <p class="row">
  143.  * <span class="textonly" translate="no">]</span><span class="head active">Home</span><span class="textonly" translate="no">[</span>
  144.  * &gt;&gt;
  145.  * <span class="textonly" translate="no">[</span><a class="sub" href="/projects/">Software projects</a><span class="textonly" translate="no">]</span>
  146.  * <span class="textonly" translate="no">[</span><a class="sub" href="/small-scripts/">Small scripts</a><span class="textonly" translate="no">]</span>
  147.  * <span class="textonly" translate="no">[</span><a class="sub" href="/linux.html">Try Linux</a><span class="textonly" translate="no">]</span>
  148.  * <span class="textonly" translate="no">[</span><a class="sub" href="/poptech-ethics.html">Our doom: popular technology</a><span class="textonly" translate="no">]</span>
  149.  * </p>
  150.  * <p class="row">
  151.  * <span class="textonly" translate="no">[</span><a class="sub" href="/policy.html">Privacy policy &amp; terms of use</a><span class="textonly" translate="no">]</span>
  152.  * <span class="textonly" translate="no">[</span><a class="sub" href="/sitemap.html">Sitemap</a><span class="textonly" translate="no">]</span>
  153.  * </p>
  154.  * <hr class="textonly"/>
  155.  * </div></div></nav>
  156.  * 
  157.  */
  158. @media not print
  159. {
  160.     #navigation {
  161.         color: #ffffff;
  162.         background-color: #0000aa;
  163.         line-height: 1.55;
  164.         font-family: sans-serif;
  165.         overflow-wrap: normal;
  166.     }
  167. }
  168. @media print
  169. {
  170.     #navigation {
  171.         display: none;
  172.     }
  173. }
  174. @media only screen and (max-width: 600px)
  175. {
  176.     #navigation {
  177.         /* The text of some links go too far */
  178.         /* 
  179.          * It's only needed on the right.
  180.          * And free space makes it easier to
  181.          * scroll past the navigation.
  182.          */
  183.         padding-right: 3em;
  184.     }
  185. }
  186. @media not print
  187. {
  188.     #nav_inner {
  189.         /* This creates a thick blue border around the navigation. */
  190.         margin: 0.75em;
  191.         padding-bottom: 0.25em;
  192.     }
  193.     #navigation a:link {
  194.         color: #aaff00;
  195.     }
  196.     #navigation a:visited {
  197.         color: #ffaa00;
  198.     }
  199.     .row {
  200.         border-bottom: 1px solid;
  201.         margin-block-start: 0.5em;
  202.         margin-block-end: 0.5em;
  203.         padding: 3px;
  204.     }
  205.     .head {
  206.         margin-right: 1.25em;
  207.         font-size: 125%;
  208.         font-weight: bold;
  209.     }
  210.     .sub {
  211.         margin-left: 1.25em;
  212.     }
  213.     /* Pseudo 3D buttons */
  214.     .row a {
  215.         background-color: #0000cc;
  216.         border-top: 2px #5555ff solid;
  217.         border-left: 2px #5555ff solid;
  218.         border-bottom: 2px #000000 solid;
  219.         border-right: 2px #000000 solid;
  220.         padding: 2px;
  221.         text-decoration: none;
  222.     }
  223.     .row .active {
  224.         background-color: #000088;
  225.         border-top: 2px #000000 solid;
  226.         border-left: 2px #000000 solid;
  227.         border-bottom: 2px #5555ff solid;
  228.         border-right: 2px #5555ff solid;
  229.         padding: 2px;
  230.     }
  231. }
  232. /*
  233.  * ### MAIN CONTENT ###
  234.  */
  235. @media not print
  236. {
  237.     /* NOTE: Allow text to be visible also for print. */
  238.     .textonly {
  239.         /* Only visible in text-based browsers, like lynx. */
  240.         /*
  241.          * I have <hr/> tags in the footer, as it isn't yellow in print.
  242.          * The navigation is fully display: none; in print.
  243.          */
  244.         display: none;
  245.     }
  246. }
  247. #content {
  248.     font-family: sans-serif;
  249. }
  250. #title {
  251.     text-align: center;
  252. }
  253. h1, h2, h3, h4, h5, h6, dt {
  254.     font-family: serif;
  255. }
  256. h2, h3, h4, h5, h6 {
  257.     margin-top: 2em;
  258. }
  259. #content p, #content dl, #content ul {
  260.     max-width: 55em;
  261. }
  262. .bold {
  263.     font-weight: bold;
  264. }
  265. .legal {
  266.     font-size: 75%;
  267.     opacity: 0.6;
  268. }
  269. img {
  270.     max-width: 100%;
  271.     height: auto;
  272. }
  273. .caption {
  274.     font-size: 110%;
  275.     font-style: italic;
  276. }
  277. li {
  278.     margin-top: 0.25em;
  279.     margin-bottom: 0.25em;
  280. }
  281. dl dl {
  282.     /* Anonymine had too much space in nested <dl>s in #platforms */
  283.     margin-block-start: 0;
  284.     margin-block-end: 0;
  285. }
  286. dt {
  287.     font-size: 125%;
  288. }
  289. dd {
  290.     margin-bottom: 2em;
  291. }
  292. pre {
  293.     white-space: pre-wrap;
  294.     max-width: 100%;
  295. }
  296. /*
  297.  * ###INNER MOBILE- AND PRINT FRIENDLINESS###
  298.  */
  299. /*
  300.  * Links on touchscreens need to be large.
  301.  * 
  302.  * .a, a        add spacing
  303.  * .a a         add no spacing
  304.  * 
  305.  * <span class="a">(<a href="foo.html">foo</a>)</span>
  306.  * will not add extra spacing: (foo)
  307.  * 
  308.  * (<a href="foo.html">foo</a>)
  309.  * will add extra spacing: (  foo  )
  310.  * 
  311.  * Ex. links in the end of a sentence are immediately followed
  312.  * by a period, which isn't in the link.
  313.  */
  314. @media only screen and (max-width: 640px), only screen and (pointer: coarse)
  315. {
  316.     #content a, #content .a, #footer a, #footer .a {
  317.         font-size: 115%;
  318.         line-height: 1.6;
  319.         margin: .25em .75em;
  320.     }
  321.     #content .a a, #footer .a a {
  322.         margin-left: 0em;
  323.         margin-right: 0em;
  324.     }
  325. }
  326. @media only screen and (max-width: 640px)
  327. {
  328.     pre {
  329.         font-size: 80%;
  330.     }
  331. }
  332. /*
  333.  * .notprint    Do not print this text/link, not needed for navigation.
  334.  * a.printurl   Print the destination URL when printing
  335.  */
  336. @media print
  337. {
  338.     .notprint {
  339.         display: none;
  340.     }
  341.     a.printurl::after {
  342.         content: ' <' attr(href) '>';
  343.     }
  344.     a.printurl {
  345.         text-decoration: none; /* Make underscores visible. */
  346.     }
  347. }
  348. /*
  349.  * ### FOOTER ###
  350.  */
  351. #footer {
  352.     margin-top: 4em;
  353. }
  354. @media not print
  355. {
  356.     #footer {
  357.         color: #000055;
  358.         background-color: #ffff80;
  359.         font-size: 75%;
  360.     }
  361.     #footer a:link, #footer a {
  362.         color: #0000aa;
  363.     }
  364.     #footer a:visited {
  365.         color: #5500aa;
  366.     }
  367.     #footer a .img {
  368.         margin-top: 1em;
  369.         margin-bottom: 1em;
  370.         margin-left: 3em;
  371.         margin-right: 3em;
  372.     }
  373. }
  374. @media print
  375. {
  376.     /*
  377.      * Greyscale footer.
  378.      */
  379.     #footer {
  380.         color: #555555;
  381.         background-color: #ffffff;
  382.         font-size: 75%;
  383.     }
  384. }