Despite this question is quite old, I found some quite hacky workaround to place summary and dropdown content into one horizontal axis. The caveat is the width of <summary>
element should be fixed, but in my case (<summary>
is an iconic button that is 24px in width and height) it works perfectly. So you apply position: absolute
to <summary>
and adjust all the other things by paddings. My case below, maybe it helps someone.
/* .panel is my <details class="panel"> */
.panel {
position: fixed; /* just my case, may be relative or absolute */
left: 0;
top: 100px;
padding: 34px 10px 10px 34px; /* top and left padding are 10px + <summary>'s size */
background: #ddd;
}
.panel summary {
margin: 0;
padding: 0;
width: 24px;
height: 24px;
cursor: pointer;
position: absolute; /* this is the trick */
left: 10px; /* imitate padding */
top: 10px; /* imitate padding */
}
.panel summary::marker,
.panel summary::-webkit-details-marker {
display: none;
content: none; /* remove triangle (my case, it is button-like) */
}
.panel[open] {
/* the 2nd part of the trick
* remove button's size from top padding when details are open,
* hence left padding remains the same.
* so visually it looks like placed into one horizontal row
* with details' dropdown content.
*/
padding-top: 10px;
}