1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
|
..
This file is part of m.css.
Copyright © 2017, 2018, 2019, 2020, 2021, 2022, 2023
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
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 OR COPYRIGHT HOLDERS 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.
..
Typography
##########
:breadcrumb: {filename}/css.rst CSS
:footer:
.. note-dim::
:class: m-text-center
`« Grid <{filename}/css/grid.rst>`_ | `CSS <{filename}/css.rst>`_ | `Components » <{filename}/css/components.rst>`_
.. role:: css(code)
:language: css
.. role:: html(code)
:language: html
.. role:: rst(code)
:language: rst
Right after being responsive, typography is the second most important thing in
m.css. The `m-components.css <{filename}/css.rst>`_ file styles the most often
used HTML elements to make them look great by default.
.. contents::
:class: m-block m-default
`Paragraphs, quotes and poems`_
===============================
Each :html:`<p>` element inside :html:`<main>` has the first line indented, is
justified and is separated from the following content by some padding. The
:html:`<blockquote>` elements are indented with a distinctive line on the left.
Because the indentation may look distracting for manually wrapped line blocks,
assign :css:`.m-poem` to such paragraph to indent all lines the same way. To
remove the indentation and justification altogether, use :css:`.m-noindent`.
Spacing between lines can be extended to 150% using :css:`.m-spacing-150`.
.. code-figure::
.. code:: html
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean id elit
posuere, consectetur magna congue, sagittis est. Pellentesque est neque,
aliquet nec consectetur in, mattis ac diam. Aliquam placerat justo ut purus
interdum, ac placerat lacus consequat.</p>
<blockquote><p>Ut dictum enim posuere metus porta, et aliquam ex condimentum.
Proin sagittis nisi leo, ac pellentesque purus bibendum sit
amet.</p></blockquote>
<p class="m-poem m-spacing-150">
Curabitur<br/>
sodales<br/>
arcu<br/>
elit</p>
<p class="m-noindent">Mauris id suscipit mauris, in scelerisque lectus. Aenean
nec nunc eu sem tincidunt imperdiet ut non elit. Integer nisi tellus,
ullamcorper vitae euismod quis, venenatis eu nulla.</p>
.. raw:: html
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean id elit
posuere, consectetur magna congue, sagittis est. Pellentesque est neque,
aliquet nec consectetur in, mattis ac diam. Aliquam placerat justo ut purus
interdum, ac placerat lacus consequat.</p>
<blockquote><p>Ut dictum enim posuere metus porta, et aliquam ex condimentum.
Proin sagittis nisi leo, ac pellentesque purus bibendum sit
amet.</p></blockquote>
<p class="m-poem m-spacing-150">
Curabitur<br/>
sodales<br/>
arcu<br/>
elit</p>
<p class="m-noindent">Mauris id suscipit mauris, in scelerisque lectus. Aenean
nec nunc eu sem tincidunt imperdiet ut non elit. Integer nisi tellus,
ullamcorper vitae euismod quis, venenatis eu nulla.</p>
`Lists, diaries`_
=================
Ordered and unordered lists have padding on bottom only on the first level.
Mark the list with :css:`.m-unstyled` to remove the asterisks/numbers and
indentation.
.. code-figure::
.. code:: html
<ul>
<li>Item 1</li>
<li>
Item 2
<ol>
<li>An item</li>
<li>Another item</li>
</ol>
</li>
<li>Item 3</li>
</ul>
<ol class="m-unstyled">
<li>Item of an unstyled list</li>
<li>Another item of an unstyled list</li>
</ol>
.. raw:: html
<ul>
<li>Item 1</li>
<li>
Item 2
<ol>
<li>An item</li>
<li>Another item</li>
</ol>
</li>
<li>Item 3</li>
</ul>
<ol class="m-unstyled">
<li>Item of an unstyled list</li>
<li>Another item of an unstyled list</li>
</ol>
It's possible to convert a list to a single line with items separated by ``|``
or ``•`` to save vertical space on mobile devices and responsively change it
back on larger screens. Mark such list with :css:`.m-block-bar-*` or
:css:`.m-block-dot-*`:
.. code-figure::
.. code:: html
<ul class="m-block-bar-m">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<ul class="m-block-dot-t">
<li>Alice</li>
<li>Bob</li>
<li>Joe</li>
</ul>
.. raw:: html
<ul class="m-block-bar-m">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<ul class="m-block-dot-t">
<li>Alice</li>
<li>Bob</li>
<li>Joe</li>
</ul>
.. note-success::
Shrink your browser window to see the effect in the above list.
Mark your definition list with :css:`.m-diary` to put the titles next to
definitions.
.. code-figure::
.. code:: html
<dl class="m-diary">
<dt>07:30:15</dt>
<dd>Woke up. The hangover is crazy today.</dd>
<dt>13:47:45</dt>
<dd>Got up from bed. Trying to find something to eat.</dd>
<dt>23:34:13</dt>
<dd>Finally put my pants on. Too late.</dd>
</dl>
.. raw:: html
<dl class="m-diary">
<dt>07:30:15</dt>
<dd>Woke up. The hangover is crazy today.</dd>
<dt>13:47:45</dt>
<dd>Got up from bed. Trying to find something to eat.</dd>
<dt>23:34:13</dt>
<dd>Finally put my pants on. Too late.</dd>
</dl>
The lists are compact by default, wrap item content in :html:`<p>` to make them
inflated. Paragraphs in list items are neither indented nor justified.
.. code-figure::
.. code:: html
<ul>
<li>
<p>Item 1, first paragraph.</p>
<p>Item 1, second paragraph.</p>
</li>
<li>
<p>Item 2</p>
<ol>
<li><p>An item</p></li>
<li><p>Another item</p></li>
</ol>
</li>
<li><p>Item 3</p></li>
</ul>
.. raw:: html
<ul>
<li>
<p>Item 1, first paragraph.</p>
<p>Item 1, second paragraph.</p>
</li>
<li>
<p>Item 2</p>
<ol>
<li><p>An item</p></li>
<li><p>Another item</p></li>
</ol>
</li>
<li><p>Item 3</p></li>
</ul>
`Headings`_
===========
The :html:`<h1>` is meant to be a page heading, thus it is styled a bit
differently --- it's bigger and has :css:`1rem` padding after. The :html:`<h2>`
to :html:`<h6>` are smaller and have just :css:`0.5rem` padding after, to be
closer to the content that follows. Wrapping part of the heading in a
:css:`.m-thin` will make it appear thinner, depending on used CSS theme.
.. code-figure::
.. code:: html
<h1>Heading 1 <span class="m-thin">with subtitle</span></h1>
<h2>Heading 2 <span class="m-thin">with subtitle</span></h2>
<h3>Heading 3 <span class="m-thin">with subtitle</span></h3>
<h4>Heading 4 <span class="m-thin">with subtitle</span></h4>
<h5>Heading 5 <span class="m-thin">with subtitle</span></h5>
<h6>Heading 6 <span class="m-thin">with subtitle</span></h6>
.. raw:: html
<h1>Heading 1 <span class="m-thin">with subtitle</span></h1>
<h2>Heading 2 <span class="m-thin">with subtitle</span></h2>
<h3>Heading 3 <span class="m-thin">with subtitle</span></h3>
<h4>Heading 4 <span class="m-thin">with subtitle</span></h4>
<h5>Heading 5 <span class="m-thin">with subtitle</span></h5>
<h6>Heading 6 <span class="m-thin">with subtitle</span></h6>
.. note-warning::
Headings are styled in a slightly different way for
`page sections <{filename}/css/page-layout.rst#main-content>`_ and
`article headers <{filename}/css/page-layout.rst#articles>`_, clicks the
links for more information. There is also a possibility to put
`breadcrumb navigation <{filename}/css/page-layout.rst#breadcrumb-navigation>`_
in the :html:`<h1>` element.
`Transitions`_
==============
Horizontal line is centered and fills 75% of the parent element. For a more
fancy transition, use :css:`.m-transition` on a paragraph.
.. code-figure::
.. code:: html
...
<hr/>
...
<p class="m-transition">~ ~ ~</p>
...
.. raw:: html
<p>Vivamus dui quam, volutpat eu lorem sit amet, molestie tristique erat.
Vestibulum dapibus est eu risus pellentesque volutpat.</p>
<hr/>
<p>Aenean tellus turpis, suscipit quis iaculis ut, suscipit nec magna.
Vestibulum finibus sit amet neque nec volutpat. Suspendisse sit amet nisl in
orci posuere mattis.</p>
<p class="m-transition">~ ~ ~</p>
<p> Praesent eu metus sed felis faucibus placerat ut eu quam. Aliquam convallis
accumsan ante sit amet iaculis. Phasellus rhoncus hendrerit leo vitae lacinia.
Maecenas iaculis dui ex, eu interdum lacus ornare sit amet.</p>
.. note-info::
Transitions can be conveniently created with a :rst:`.. transition::`
directive in your :abbr:`reST <reStructuredText>` markup using the
`Pelican Components plugin <{filename}/plugins/components.rst#transitions>`_.
`Preformatted blocks`_
======================
The :html:`<pre>` element preserves your whitespace and adds a convenient
scrollbar if the content is too wide. If inside an
`inflatable nested grid <{filename}/css/grid.rst#inflatable-nested-grid>`_, it
will have negative margin to make its contents aligned with surrounding text.
.. code-figure::
.. code:: html
<pre>
int main() {
return 0;
}
</pre>
.. raw:: html
<pre>
int main() {
return 0;
}
</pre>
.. note-info::
The Components page has additional information about
`code block styling <{filename}/css/components.rst#code>`_.
`Footnotes and footnote references`_
====================================
Applying :css:`.m-footnote` to a link will turn it into a footnote reference
--- a superscript, wrapped in brackets. For the actual footnotes use
:html:`<dl class="m-footnote">`; :html:`<dt>` contains footnote ID and
:html:`<dd>` the footnote text. You can add a :html:`<span class="m-footnote">`
inside the :html:`<dd>` to provide styled back-references to the original text.
.. code-figure::
.. code:: html
<p>
As also noted in the court case of <em>Mondays vs The Working People</em>
<a href="#ref1" class="m-footnote" id="ref1-backref">1</a>, the transition
between the weekend and a working day has a similar impact on overall
happines as a transition between holidays and working days, however not as
significant <a href="#ref2" class="m-footnote" id="ref2-backref">2</a>.
This is a common theme of small talk conversations, together with
weather <a href="#ref1" class="m-footnote" id="ref1-backref2">1</a>
<a href="#ref3" class="m-footnote" id="ref3-backref">3</a>.
</p>
<dl class="m-footnote">
<dt id="ref1">1.</dt>
<dd>
<span class="m-footnote">^ <a href="#ref1-backref">a</a>
<a href="#ref1-backref2">b</a></span> Mondays vs The Working People,
The Arizona Highest Court, 2019
</dd>
<dt id="ref2">2.</dt>
<dd>
<span class="m-footnote"><a href="#ref2-backref">^</a></span>
<a href="https://garfield.com/comic/2014/05/26">Garfield; Monday,
May 26, 2014</a>
</dd>
<dt id="ref3">3.</dt>
<dd>
<span class="m-footnote"><a href="#ref3-backref">^</a></span> From a
conversation overheard this very morning.
</dd>
</dl>
.. raw:: html
<p>
As also noted in the court case of <em>Mondays vs The Working People</em>
<a href="#ref1" class="m-footnote" id="ref1-backref">1</a>, the transition
between the weekend and a working day has a similar impact on overall
happines as a transition between holidays and working days, however not as
significant <a href="#ref2" class="m-footnote" id="ref2-backref">2</a>.
This is a common theme of small talk conversations, together with
weather <a href="#ref1" class="m-footnote" id="ref1-backref2">1</a>
<a href="#ref3" class="m-footnote" id="ref3-backref">3</a>.
</p>
<dl class="m-footnote">
<dt id="ref1">1.</dt>
<dd>
<span class="m-footnote">^ <a href="#ref1-backref">a</a>
<a href="#ref1-backref2">b</a></span> Mondays vs The Working People,
The Arizona Highest Court, 2019
</dd>
<dt id="ref2">2.</dt>
<dd>
<span class="m-footnote"><a href="#ref2-backref">^</a></span>
<a href="https://garfield.com/comic/2014/05/26">Garfield; Monday,
May 26, 2014</a>
</dd>
<dt id="ref3">3.</dt>
<dd>
<span class="m-footnote"><a href="#ref3-backref">^</a></span> From a
conversation overheard this very morning.
</dd>
</dl>
`Text alignment and wrapping`_
==============================
Use :css:`.m-text-left`, :css:`.m-text-right` or :css:`.m-text-center` to
align text inside its parent element. Use :css:`.m-text-top`,
:css:`.m-text-middle` and :css:`.m-text-bottom` to align text vertically for
example in a table cell. See `Floating around <{filename}/css/grid.rst#floating-around>`_
in the grid system for aligning and floating blocks in a similar way.
By default, all text is wrapped according to default HTML rules. In order to
look better on very narrow screens, it's possible to use :html:`­` to
hyphenate words. The :html:`<wbr/>` HTML tag does the same without rendering
any hyphens, and finally there's a :css:`.m-link-wrap` you can apply to links
with long URLs to break anywhere. Both hyphenation and link wrapping can be
done either manually on a case-by-case basis, or using the
`m.htmlsanity plugin <{filename}/plugins/htmlsanity.rst>`_, which can do both
automatically.
.. code-figure::
.. code:: html
in­com­pre­hen­si­bil­i­ties
in<wbr/>com<wbr/>pre<wbr/>hen<wbr/>si<wbr/>bil<wbr/>i<wbr/>ties
<a href="http://…" class="m-link-wrap">
llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch.co.uk
</a>
.. container:: m-row
.. container:: m-col-m-2 m-push-m-2 m-col-t-3 m-nopady
.. raw:: html
in­com­pre­hen­si­bil­i­ties
.. container:: m-col-m-2 m-push-m-2 m-col-t-3 m-nopady
.. raw:: html
in<wbr/>com<wbr/>pre<wbr/>hen<wbr/>si<wbr/>bil<wbr/>i<wbr/>ties
.. container:: m-col-m-4 m-push-m-2 m-col-t-6 m-nopady
.. raw:: html
<a href="http://llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch.co.uk" class="m-link-wrap">
llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch.co.uk
</a>
`Inline elements`_
==================
.. code-figure::
.. code:: html
A <a href="#">link</a>, <em>emphasised text</em>, <strong>strong text</strong>,
<abbr title="abbreviation">abbr</abbr> shown inside a normal text flow to
verify that they don't break text flow. Then there is <small>small text</small>,
<sup>super</sup>, <sub>sub</sub> and <s>that is probably all I can think of
right now</s> oh, there is also <mark>marked text</mark> and
<code>int a = some_code();</code>.
.. raw:: html
A <a href="#">link</a>, <em>emphasised text</em>, <strong>strong text</strong>,
<abbr title="abbreviation">abbr</abbr> shown inside a normal text flow to
verify that they don't break text flow. Then there is <small>small text</small>,
<sup>super</sup>, <sub>sub</sub> and <s>that is probably all I can think of
right now</s> oh, there is also <mark>marked text</mark> and
<code>int a = some_code();</code>.
Links are underlined by default in all `builtin themes <{filename}/css/themes.rst>`_.
Adding :css:`.m-flat` to the :html:`<a>` element will remove the underline,
useful where underlines would be too distracting:
.. code-figure::
.. code:: html
<p class="m-text-center m-text m-dim">
There is a <a href="#" class="m-flat">hidden</a> link.
</p>
.. raw:: html
<p class="m-text-center m-text m-dim">
There is a <a href="#" class="m-flat">hidden</a> link.
</p>
For cases where you can't use the native HTML tags for emphasis, strong text,
strikethrough and subscript/superscript, the equivalent is available through
:css:`.m-em`, :css:`.m-strong`, :css:`.m-s`, :css:`.m-sup` and :css:`.m-sub`
CSS classes used together with :css:`.m-text`.
.. note-info::
The Components page has additional information about
`text styling <{filename}/css/components.rst#text>`_.
`Padding`_
==========
Block elements :html:`<p>`, :html:`<ol>`, :html:`<ul>`, :html:`<dl>`,
:html:`<blockqote>`, :html:`<pre>` and :html:`<hr>` by default have :css:`1rem`
padding on the bottom, except when they are the last child, to avoid excessive
spacing. A special case is lists --- components directly inside :html:`<li>`
elements have :css:`1rem` padding on the bottom, except when the :html:`<li>`
is last, to achieve consistent spacing for inflated lists.
The :css:`1rem` padding on the bottom can be disabled with :css:`.m-nopadb`,
similarly as with `grid layouts <{filename}/css/grid.rst#grid-padding>`_. On
the other hand, if you want to preserve it, add an empty :html:`<div></div>`
element after.
|