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 399

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.     }
  204.     .head {
  205.         margin-right: 1.25em;
  206.         font-size: 125%;
  207.         font-weight: bold;
  208.     }
  209.     .sub {
  210.         margin-left: 1.25em;
  211.     }
  212.     /* Pseudo 3D buttons */
  213.     .row a {
  214.         background-color: #0000cc;
  215.         border-top: 2px #5555ff solid;
  216.         border-left: 2px #5555ff solid;
  217.         border-bottom: 2px #000000 solid;
  218.         border-right: 2px #000000 solid;
  219.         padding: 2px;
  220.         text-decoration: none;
  221.     }
  222.     .row .active {
  223.         background-color: #000088;
  224.         border-top: 2px #000000 solid;
  225.         border-left: 2px #000000 solid;
  226.         border-bottom: 2px #5555ff solid;
  227.         border-right: 2px #5555ff solid;
  228.         padding: 2px;
  229.     }
  230. }
  231. /*
  232.  * ### MAIN CONTENT ###
  233.  */
  234. @media not print
  235. {
  236.     /* NOTE: Allow text to be visible also for print. */
  237.     .textonly {
  238.         /* Only visible in text-based browsers, like lynx. */
  239.         /*
  240.          * I have <hr/> tags in the footer, as it isn't yellow in print.
  241.          * The navigation is fully display: none; in print.
  242.          */
  243.         display: none;
  244.     }
  245. }
  246. #content {
  247.     font-family: sans-serif;
  248. }
  249. #title {
  250.     text-align: center;
  251. }
  252. h1, h2, h3, h4, h5, h6, dt {
  253.     font-family: serif;
  254. }
  255. h2, h3, h4, h5, h6 {
  256.     margin-top: 2em;
  257. }
  258. #content p, #content dl, #content ul {
  259.     max-width: 55em;
  260. }
  261. .bold {
  262.     font-weight: bold;
  263. }
  264. .legal {
  265.     font-size: 75%;
  266.     opacity: 0.6;
  267. }
  268. img {
  269.     max-width: 100%;
  270.     height: auto;
  271. }
  272. .caption {
  273.     font-size: 110%;
  274.     font-style: italic;
  275. }
  276. li {
  277.     margin-top: 0.25em;
  278.     margin-bottom: 0.25em;
  279. }
  280. dl dl {
  281.     /* Anonymine had too much space in nested <dl>s in #platforms */
  282.     margin-block-start: 0;
  283.     margin-block-end: 0;
  284. }
  285. dt {
  286.     font-size: 125%;
  287. }
  288. dd {
  289.     margin-bottom: 2em;
  290. }
  291. pre {
  292.     white-space: pre-wrap;
  293.     max-width: 100%;
  294. }
  295. /*
  296.  * ###INNER MOBILE- AND PRINT FRIENDLINESS###
  297.  */
  298. /*
  299.  * Links on touchscreens need to be large.
  300.  * 
  301.  * .a, a        add spacing
  302.  * .a a         add no spacing
  303.  * 
  304.  * <span class="a">(<a href="foo.html">foo</a>)</span>
  305.  * will not add extra spacing: (foo)
  306.  * 
  307.  * (<a href="foo.html">foo</a>)
  308.  * will add extra spacing: (  foo  )
  309.  * 
  310.  * Ex. links in the end of a sentence are immediately followed
  311.  * by a period, which isn't in the link.
  312.  */
  313. @media only screen and (max-width: 640px), only screen and (pointer: coarse)
  314. {
  315.     #content a, #content .a, #footer a, #footer .a {
  316.         font-size: 115%;
  317.         line-height: 1.6;
  318.         margin: .25em .75em;
  319.     }
  320.     #content .a a, #footer .a a {
  321.         margin-left: 0em;
  322.         margin-right: 0em;
  323.     }
  324. }
  325. @media only screen and (max-width: 640px)
  326. {
  327.     pre {
  328.         font-size: 80%;
  329.     }
  330. }
  331. /*
  332.  * .notprint    Do not print this text/link, not needed for navigation.
  333.  * a.printurl   Print the destination URL when printing
  334.  */
  335. @media print
  336. {
  337.     .notprint {
  338.         display: none;
  339.     }
  340.     a.printurl::after {
  341.         content: ' <' attr(href) '>';
  342.     }
  343.     a.printurl {
  344.         text-decoration: none; /* Make underscores visible. */
  345.     }
  346. }
  347. /*
  348.  * ### FOOTER ###
  349.  */
  350. #footer {
  351.     margin-top: 4em;
  352. }
  353. @media not print
  354. {
  355.     #footer {
  356.         color: #000055;
  357.         background-color: #ffff80;
  358.         font-size: 75%;
  359.     }
  360.     #footer a:link, #footer a {
  361.         color: #0000aa;
  362.     }
  363.     #footer a:visited {
  364.         color: #5500aa;
  365.     }
  366.     #footer a .img {
  367.         margin-top: 1em;
  368.         margin-bottom: 1em;
  369.         margin-left: 3em;
  370.         margin-right: 3em;
  371.     }
  372. }
  373. @media print
  374. {
  375.     /*
  376.      * Greyscale footer.
  377.      */
  378.     #footer {
  379.         color: #555555;
  380.         background-color: #ffffff;
  381.         font-size: 75%;
  382.     }
  383. }