admin管理员组文章数量:1336212
I have a list with a "details" button for almost every entry in it. Currently it looks like this:
.spoiler {display:inline;margin: 1px;}
details[open] > summary {}
summary {cursor:pointer;font-size:14px;}
summary:focus {box-shadow: none !important;}
summary > p {display:inline;}
<ol>
<li>Apple</li>
<details class="spoiler" style="display:inline;border: 1px solid #aaa;border-radius: 4px;padding: 2px;">
<summary>
<b>more...</b>
</summary> <img src=".png" width="100px"></details>
<li>Banana</li>
<li>Orange</li>
</ol>
I have a list with a "details" button for almost every entry in it. Currently it looks like this:
.spoiler {display:inline;margin: 1px;}
details[open] > summary {}
summary {cursor:pointer;font-size:14px;}
summary:focus {box-shadow: none !important;}
summary > p {display:inline;}
<ol>
<li>Apple</li>
<details class="spoiler" style="display:inline;border: 1px solid #aaa;border-radius: 4px;padding: 2px;">
<summary>
<b>more...</b>
</summary> <img src="https://www.applesfromny/wp-content/uploads/2020/05/20Ounce_NYAS-Apples2.png" width="100px"></details>
<li>Banana</li>
<li>Orange</li>
</ol>
Unfortunately, those buttons take a lot of vertical space and look ugly in a structured list. I want them to move to the end of each bullet's text. Then, when pressed, to show the hidden content in a new line and if pressed again, to hide back. Something like that:
example
Is it possible? Your help is highly appreciated. Thank you.
Share Improve this question asked Nov 20, 2024 at 15:15 Geiy ShoulgaGeiy Shoulga 211 silver badge3 bronze badges 1 |1 Answer
Reset to default 1Rearrange the HTML slightly to comply with standards and make the details
element a child of the li
.
.spoiler {
display: inline-block;
vertical-align: top;
margin: 1px;
}
details[open]>summary {}
summary {
cursor: pointer;
font-size: 14px;
}
summary:focus {
box-shadow: none !important;
}
summary>p {
display: inline;
}
<ol>
<li>Apple
<details class="spoiler">
<summary>
<b>more...</b>
</summary> <img src="https://www.applesfromny/wp-content/uploads/2020/05/20Ounce_NYAS-Apples2.png" width="100px"></details>
</li>
<li>Banana</li>
<li>Orange</li>
</ol>
本文标签: htmlDetails (showhide) button in one linebut in a new line after expandedStack Overflow
版权声明:本文标题:html - Details (showhide) button in one line, but in a new line after expanded - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742350334a2458362.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
details
element cannot be a child of anol
element. – Sean Commented Nov 20, 2024 at 15:17