0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-26 23:54:23 +01:00

WIP on new .content-body class

This commit is contained in:
Mark Otto 2025-02-26 10:58:15 -08:00
parent 505b52b419
commit ea25cec081
4 changed files with 236 additions and 1 deletions

View File

@ -0,0 +1,112 @@
@use "../config" as *;
@use "../mixins/transition" as *;
@layer content {
.content-body {
--#{$prefix}content-font-size: 16px;
--#{$prefix}content-gap: 24px;
position: relative;
max-width: 1000px;
margin-inline: auto;
font-size: var(--#{$prefix}content-font-size);
line-height: var(--#{$prefix}content-gap);
p,
ul,
ol,
dl,
pre,
table,
blockquote {
margin-bottom: var(--#{$prefix}content-gap);
}
li:not(:last-child) {
margin-bottom: calc(var(--#{$prefix}content-gap) / 4);
}
hr {
margin: calc(var(--#{$prefix}content-gap) * 1.5) 0;
border: 0;
border-top: 1px solid var(--#{$prefix}border-color);
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin-top: 0;
margin-bottom: calc(var(--#{$prefix}content-gap) / 2);
font-weight: 500;
line-height: 1.25;
}
h1 {
font-size: 2.25em;
line-height: 1.1;
}
h2 {
font-size: 1.75em;
}
h3 {
margin-bottom: calc(var(--#{$prefix}content-gap) / 4);
font-size: 1.5em;
}
h4 {
font-size: 1.25em;
}
h5 {
font-size: 1.125em;
}
h6 {
font-size: 1em;
}
a:not([class]) {
color: var(--ui-theme-primary-text);
text-decoration: underline;
text-decoration-color: color-mix(in srgb, var(--ui-theme-primary-text) 25%, transparent);
text-underline-offset: 4px;
@include transition(.1s text-decoration-color ease-in-out);
}
a:not([class]):hover {
text-decoration-color: var(--ui-theme-primary-text);
}
img {
max-width: 100%;
}
blockquote {
padding-left: calc(var(--#{$prefix}content-gap) / 2);
margin: 0;
border-left: 4px solid var(--#{$prefix}border-color);
}
table {
width: 100%;
border-spacing: 0;
border-collapse: collapse;
}
td,
th {
padding: 6px 12px;
text-align: inherit;
border: 1px solid var(--#{$prefix}border-color);
}
dt {
font-weight: 500;
}
video,
img {
max-width: 100%;
}
}
}

View File

@ -2,3 +2,4 @@
@forward "type";
@forward "tables";
@forward "images";
@forward "content-body";

View File

@ -52,7 +52,7 @@
- title: Images
- title: Tables
- title: Figures
- title: Content body
- title: Forms
icon: ui-radios
icon_color: blue

View File

@ -0,0 +1,122 @@
---
title: Content body
description: Use the `.content-body` wrapper class to make long form content more easily without the need for specifying Bootstrap classes on every element. Especially useful for converting Markdown or MDX to HTML, or simply for making content heavy pages more readable.
toc: true
---
## How it works
Wrap your content in the `.content-body` class to get modified font-size, line-height, and spacing specifically designed for long form content that originals from source Markdown files or WYSIWYG editors. Here's what we do with that class:
- Set a base `font-size`, `line-height`, and some local CSS variables on the parent element.
- Normalize the spacing of lists
- Set a default `margin-bottom` for headings.
- Style blockquotes, code, and other inline elements.
## Example
This is an example of source Markdown that shows several types of HTML content supported in this `.content-body` wrapper class.
<div class="bd-example content-body">
# Lorem ipsum dolor sit amet
Cum sociis natoque penatibus et magnis [dis parturient montes](#), nascetur ridiculus mus. *Aenean eu leo quam.* Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.
> Curabitur blandit tempus porttitor. Nullam quis risus eget urna mollis ornare vel eu leo. Nullam id dolor id nibh ultricies vehicula ut id elit.
Etiam porta **sem malesuada magna** mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.
## Inline HTML elements
HTML defines a long list of available inline tags, a complete list of which can be found on the [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/HTML/Element).
- **To bold text**, use `<strong>`.
- *To italicize text*, use `<em>`.
- <mark>To highlight</mark>, use `<mark>`.
- Abbreviations, like <abbr title="HyperText Markup Langage">HTML</abbr> should use `<abbr>`, with an optional `title` attribute for the full phrase.
- Citations, like <cite>&mdash; Mark Otto</cite>, should use `<cite>`.
- <del>Deleted</del> text should use `<del>` and <ins>inserted</ins> text should use `<ins>`.
- Superscript <sup>text</sup> uses `<sup>` and subscript <sub>text</sub> uses `<sub>`.
Most of these elements are styled by browsers with few modifications on our part.
## Heading
Vivamus sagittis lacus vel augue rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
### Code
Inline code is available with the `<code>` element. Snippets of multiple lines of code are supported through Rouge. Longer lines will automatically scroll horizontally when needed. You may also use code fencing (triple backticks) for rendering code.
```
// Example can be run directly in your JavaScript console
// Create a function that takes two arguments and returns the sum of those arguments
var adder = new Function("a", "b", "return a + b");
// Call the function
adder(2, 6);
// > 8
```
Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.
### Lists
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
- Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
- Donec id elit non mi porta gravida at eget metus.
- Nulla vitae elit libero, a pharetra augue.
Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue.
1. Vestibulum id ligula porta felis euismod semper.
2. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
3. Maecenas sed diam eget risus varius blandit sit amet non magna.
Cras mattis consectetur purus sit amet fermentum. Sed posuere consectetur est at lobortis.
- Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
- Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
- Donec id elit non mi porta gravida at eget metus.
- Nulla vitae elit libero, a pharetra augue.
- Donec id elit non mi porta gravida at eget metus.
- Nulla vitae elit libero, a pharetra augue.
Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
<dl>
<dt>HyperText Markup Language (HTML)</dt>
<dd>The language used to describe and define the content of a Web page</dd>
<dt>Cascading Style Sheets (CSS)</dt>
<dd>Used to describe the appearance of Web content</dd>
<dt>JavaScript (JS)</dt>
<dd>The programming language used to build advanced Web sites and applications</dd>
</dl>
Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Nullam quis risus eget urna mollis ornare vel eu leo.
### Images
Quisque consequat sapien eget quam rhoncus, sit amet laoreet diam tempus. Aliquam aliquam metus erat, a pulvinar turpis suscipit at.
![placeholder](http://placehold.it/800x400 "Large example image")
![placeholder](http://placehold.it/400x200 "Medium example image")
![placeholder](http://placehold.it/200x200 "Small example image")
### Tables
Aenean lacinia bibendum nulla sed consectetur. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
| Name | Upvotes | Downvotes |
|---------|---------|-----------|
| Alice | 10 | 11 |
| Bob | 4 | 3 |
| Charlie | 7 | 9 |
| Totals | 21 | 23 |
Nullam id dolor id nibh ultricies vehicula ut id elit. Sed posuere consectetur est at lobortis. Nullam quis risus eget urna mollis ornare vel eu leo.
</div>