I'm making text bold on hover, but since it's moving so much when it's on hover, it looks odd now. Here's what it looks like: https://i.stack.imgur.com/AtVjT.jpg
Update: To clarify, I think the selected answer here Inline elements shifting when made bold on hover should work in my case - it indeed worked for another set of code I wrote elsewhere. However, it's not working for this set of code, and I'm not sure why. Is there something wrong with my code here?
.accordion::before {
display: block;
content: attr(title);
font-family: 'Gotham-Medium';
height: 0;
overflow: hidden;
visibility: hidden;
}
Thanks in advance
Html:
<button class="accordion" title="Lorem ipsum dolor sit amet?">Lorem ipsum dolor sit amet?</button>
<div class="panel">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod temp.</p>
</div>
<button class="accordion">Lorem ipsum dolor sit amet?</button>
<div class="panel">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod temp.</p>
</div>
.accordion {
background-color:#FFFFFF;
color: #67636E;
color: var(--main-color);
cursor: pointer;
width: 100%;
text-align: left;
border: none;
outline: none;
transition: 0.4s;
margin-top: 0;
margin-bottom: 0;
line-height: 1.9;
}
.active, .accordion:hover {
font-family: 'Gotham-Medium'
}
.accordion::before {
display: block;
content: attr(title);
font-weight: bold;
height: 0;
overflow: hidden;
visibility: hidden;
}
.panel {
background-color: white;
overflow: hidden;
max-height: 0;
transition: max-height 0.3s ease-out;
margin-top: 0;
margin-bottom: 0;
}