我使用details
来使内容部分可折叠。我已经将summary h3
设置为display: inline-block;
,因此标记与标题一致。
不幸的是,当标题换行到多行时,标记会跳到标题上方。
如何确保即使是多行摘要也有合理的标记位置?
summary h3 {
display: inline-block;
}
<details>
<summary>
<h3>Short line</h3>
</summary>
</details>
<details>
<summary>
<h3>Wow very long line, I hope this wraps sensibly and keeps the arrow in a good place.</h3>
</summary>
</details>
<details>
<summary>
<h3>Wow very long line, I hope this wraps sensibly and keeps the arrow in a good place. Wow very long line, I hope this wraps sensibly and keeps the arrow in a good place. Wow very long line, I hope this wraps sensibly and keeps the arrow in a good place.</h3>
</summary>
</details>
1条答案
按热度按时间iyfamqjs1#
稍微做个造型就可以了。关闭标准的列表标记,添加你自己的伪元素,然后使整个东西成为一个flexbox。
请注意,虽然技术上允许将
<h3>
放入<summary>
中,但我更喜欢保持简单。