I'm working on my Hugo site (repo here). I want to add a details element next to anchors, all styled to look the same, as shown in the first screenshot ("abstract" is the details element that reveals the abstract when clicked; "paper" and "slides" are links to PDFs).
But when the details element is open, this pushes the anchors below the text of the abstract, as shown in the second screenshot.
Is it possible to keep the anchors in their position from the first screenshot when the details element is open?
Here's the markup for the page:
## working papers
1. **A dynamic spatial knowledge economy** (JMP) <br>
<details>
<summary>abstract</summary>
Cities have long been thought to drive economic growth. ...
</details>
<a href="/files/p-dske_paper.pdf" class="button">paper</a>
<a href="/files/p-dske_slides.pdf" class="button">slides</a>
And here's the custom CSS I'm currently hacking on (would go in static/css/custom.css):
details {
display: inline-block;
margin-bottom: 1em;
}
summary {
background-color: #EBEBEB;
border: none;
color: #2774AE;
padding: 5px;
text-align: center;
text-decoration: none;
display: inline;
font-size: 12px;
margin: 1px;
border-radius: 10px;
}
summary:hover {
background: #FFC72C;
}
details>summary {
list-style: none;
}
details>summary::-webkit-details-marker {
display: none;
}
details[open] summary {
display: -webkit-inline-flex;
position: relative;
top: 0px;
right: 0%;
margin-bottom: 0.5em;
}
.button {
background-color: #EBEBEB;
border: none;
color: #2774AE;
padding: 5px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
margin: 1px;
border-radius: 10px; /* rounded corners */
}
.button:hover {
background-color: #FFC72C;
color: #2774AE;
}


You need to group the trigger and links together, and have the content live outside of that group. Then using JS, you can toggle visibility of that content using an event listener, the event being the mouse click.
Update:
Initially I wasn't sure if you needed this to support multiple sections, and it looks like you do. The way this is set up is that the button triggers (inside nav) have an attribute called
data-navfollowed by a number. If you look inside the details div, there are content blocks that have an attribute calleddata-summaryfollowed by a number. The JS will watch for the button triggers to be clicked. Once they are, it will take thatdata-navnumber, and check for details div's with the same number assigned to thedata-summaryattribute. If it already has.showthat makes it visible, then it will remove it. If it doesn't have that class, then it will remove that class from all of the other items (in case it's active somewhere else) and then add it to the one you just clicked.