mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Merge commit '346b60358dd8ec2ca228e6635bff9d7914b398b7'
This commit is contained in:
80
docs/content/en/shortcodes/details.md
Executable file
80
docs/content/en/shortcodes/details.md
Executable file
@@ -0,0 +1,80 @@
|
||||
---
|
||||
title: Details
|
||||
description: Insert an HTML details element into your content using the details shortcode.
|
||||
categories: [shortcodes]
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: shortcodes
|
||||
weight:
|
||||
weight:
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< new-in 0.140.0 >}}
|
||||
|
||||
{{% note %}}
|
||||
To override Hugo's embedded `details` shortcode, copy the [source code] to a file with the same name in the `layouts/shortcodes` directory.
|
||||
|
||||
[source code]: {{% eturl details %}}
|
||||
{{% /note %}}
|
||||
|
||||
## Example
|
||||
|
||||
With this markup:
|
||||
|
||||
```text
|
||||
{{</* details summary="See the details" */>}}
|
||||
This is a **bold** word.
|
||||
{{</* /details */>}}
|
||||
```
|
||||
|
||||
Hugo renders this HTML:
|
||||
|
||||
```html
|
||||
<details>
|
||||
<summary>See the details</summary>
|
||||
<p>This is a <strong>bold</strong> word.</p>
|
||||
</details>
|
||||
```
|
||||
|
||||
Which looks like this in your browser:
|
||||
|
||||
{{< details summary="See the details" >}}
|
||||
This is a **bold** word.
|
||||
{{< /details >}}
|
||||
|
||||
## Parameters
|
||||
|
||||
summary
|
||||
: (`string`) The content of the child `summary` element rendered from Markdown to HTML. Default is `Details`.
|
||||
|
||||
open
|
||||
: (`bool`) Whether to initially display the content of the `details` element. Default is `false`.
|
||||
|
||||
class
|
||||
: (`string`) The `class` attribute of the `details` element.
|
||||
|
||||
name
|
||||
: (`string`) The `name` attribute of the `details` element.
|
||||
|
||||
title
|
||||
: (`string`) The `title` attribute of the `details` element.
|
||||
|
||||
## Styling
|
||||
|
||||
Use CSS to style the `details` element, the `summary` element, and the content itself.
|
||||
|
||||
```css
|
||||
/* target the details element */
|
||||
details { }
|
||||
|
||||
/* target the summary element */
|
||||
details > summary { }
|
||||
|
||||
/* target the children of the summary element */
|
||||
details > summary > * { }
|
||||
|
||||
/* target the content */
|
||||
details > :not(summary) { }
|
||||
```
|
Reference in New Issue
Block a user