这是我努力的目标
> Variable Length Title: A sentence worth of text that may or may
not wrap depending upon the width of the
container.
This is the text that is not in the
summary tag but still is in the details
tag therefore hidden unless clicked on.
字符串
html看起来像
<details>
<summary>
<span class="left">Variable Length Title:</span>
<span class="right">
A sentence worth of text that may or may
not wrap depending upon the width of the
container.
</span>
</summary>
<p>
This is the text that is not in the
summary tag but still is in the details
tag therefore hidden unless clicked on.
</p>
</details>
型
我能想到的一个不太好的解决方案是将.left
的宽度设置为display: inline-block;
,并为details p
设置左填充,但这仍然给我留下了文本换行的问题,换行的文本从行的开头开始。
如果可能的话,我正在寻找CSS的唯一解决方案。
2条答案
按热度按时间whlutmcx1#
如果你可以稍微修改HTML,你可以这样做:
<p>
的前一个同级文件。visibility: hidden;
隐藏它但保持它的宽度。<div>
Package 起来。个字符
qij5mzcb2#
个字符
好的!在使用详细信息>摘要时必须非常小心。如果你正在使用大规模的应用程序,那么我建议你使用标签/ accordion /折叠。
下面是CSS代码:
型
下面是更新后的HTML代码:
型