UPDATE 5/3/2021
Today, I went back to my solution and completed the unfinished parts from yesterday. Several enhancements and stylistic improvements were also added. The parent #mega-button
now features a gradient background that smoothly transitions to a faded blue-gray color by utilizing an oversized gradient and transitioning the background-position
property. As a hover effect, this button decreases in size while the child elements of .sub-button
rotate and increase in size, giving the impression that they are rolling out from behind the #mega-button
.
To create a smoother and more natural transition, I introduced a slight transition-delay
between each of the .sub-button
elements, resulting in a waterfall effect instead of all buttons appearing simultaneously. To achieve this unique position per .sub-button
, I used a for loop in my SCSS, iterating in reverse for the transition-delay
so that the right-most button animates out first.
I also incorporated some glassmorphism styles to give the #mega-button
a subtle frosted glass appearance as the buttons roll out from behind it: backdrop-filter: blur(4px)
When any of the child buttons are clicked, they open their respective modal using :target
. Each modal provides multiple options for closing purely with HTML/CSS:
- Clicking on the translucent background behind the modal.
- Clicking the close button "x" in the top-right corner.
- Clicking the "Cancel" action button.
Every modal is unique and triggered by its corresponding .sub-button
. Additionally, I established a modular system for the modal styles, including global styles for .modal-content
, .modal-header
, and .modal-body
, along with contextual styles for the .modal-close
class that serves as the clickable/cancellable backdrop when placed within the modal's main element or as the "x" in the corner if located within .modal-content
. Clicking either will close the modal.
Two additional features I included today:
- Styling for a "new post" form with dynamic spacing capabilities, and generic styles for a brief alert modal used for Archive and Delete actions.
- A hover tooltip displayed over the
#mega-button
. This tooltip is non-interactive and does not obstruct content behind it due to its pointer-events: none
property. It fades away with opacity: 0
when hovering over the #mega-button
or its descendants, or if a modal is open, via the general sibling combinator (~
).
The final product can be viewed here:
@charset "UTF-8";
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap");
.modal .modal-content .modal-body {
-ms-overflow-style: none;
scrollbar-width: none;
}
/* Other CSS rules follow... */
<script src="https://kit.fontawesome.com/07afc061fe.js" crossorigin="anonymous"></script>
<div id="modal-write" class="modal">
<a href="#" class="modal-close"></a>
/* Modal content goes here */
</div>
/* More modal code... */
</div>
For the original CodePen showcasing this solution with all its Sass characteristics, click here: https://codepen.io/brandonmcconnell/pen/082f4ee58d234501757b8d6a748c514b?editors=0100
If preferred, all dynamic variables in the SCSS can easily be converted to CSS custom properties to maintain dynamic calculations in the final CSS file.