Skip to content

Instantly share code, notes, and snippets.

@mikeoberdick
Created June 2, 2021 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeoberdick/338f551810c07bd2767abc380cf29a79 to your computer and use it in GitHub Desktop.
Save mikeoberdick/338f551810c07bd2767abc380cf29a79 to your computer and use it in GitHub Desktop.
Morph a plus icon into a minus icon for accordians and menus
/*
<div class = "plus-to-minus">
<span></span>
<span></span>
</div>
*/
.question-container {
.plus-to-minus {
width: 50px;
height: 50px;
font-size: 1.5em;
position: relative;
span {
position: absolute;
transition: 300ms;
background: $purple;
border-radius: 2px;
&:first-child {
top: 25%;
bottom: 25%;
width: 10%;
left: 45%;
}
&:last-child {
left: 25%;
right: 25%;
height: 10%;
top: 45%;
}
}
}
a[aria-expanded="true"] {
.plus-to-minus {
span {
transform: rotate(90deg);
&:last-child {
left: 50%;
right: 50%;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment