We create a number of custom menu hover effects for many of our clients and child themes so I decided it is time to get some of those tutorials into your hands.
In this tutorial I am going to show you how you can make top and bottom borders criss-cross into the form of an X for each menu item.
*Note: This customization will not work correctly if you have drop down sub-menus. That will require additional modifications not yet available on this tutorial.
Let’s Get Started Making The Divi Menu Criss-Crossing Borders
Adding The Custom CSS
If you are working with a child theme you can go to Appearance>Editor and open your stylesheet. If not, go to Appearance>Divi Theme Options>Custom CSS (which is located at the bottom of the first tab in Theme Options)
Add this CSS.
/*------------------------------------------------*/ /*------------[GQ - CROSSING BORDERS]-------------*/ /*------------------------------------------------*/ #et-top-navigation { padding-top: 20px; padding-bottom: 40px;} #top-menu-nav > ul > li > { position: relative; z-index: 1;} #top-menu-nav > ul > li > a { padding: 0 5px; font-weight: 700; -webkit-transition: color 0.3s; -moz-transition: color 0.3s; transition: color 0.3s;} #top-menu-nav > ul > li > a::before, #top-menu-nav > ul > li > a::after { position: absolute; width: 100%; left: 0; top: 50%; height: 1px; margin-top: -1px; background: rgba(183, 183, 183, 0.5); content: ''; z-index: -1; -webkit-transition: -webkit-transform 0.3s, opacity 0.3s; -moz-transition: -moz-transform 0.3s, opacity 0.3s; transition: transform 0.3s, opacity 0.3s; pointer-events: none;} #top-menu-nav > ul > li > a::before { -webkit-transform: translateY(-20px); -moz-transform: translateY(-20px); transform: translateY(-20px);} #top-menu-nav > ul > li > a::after { -webkit-transform: translateY(20px); -moz-transform: translateY(20px); transform: translateY(20px);} #top-menu-nav > ul > li > a:hover, #top-menu-nav > ul > li > a:focus { color: #08445f;} #top-menu-nav > ul > li > a:hover::before, #top-menu-nav > ul > li > a:hover::after, #top-menu-nav > ul > li > a:focus::before, #top-menu-nav > ul > li > a:focus::after { opacity: 0.3; background: #08445f;} #top-menu-nav > ul > li > a:hover::before, #top-menu-nav > ul > li > a:focus::before { -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); transform: rotate(45deg);} #top-menu-nav > ul > li > a:hover::after, #top-menu-nav > ul > li > a:focus::after { -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); transform: rotate(-45deg);}
Making Adjustments
Now because there are already so many menu padding options available in the Theme Customizer, there is a good chance you may have to adjust the bottom padding of the main buttons. You can change that here. You can also change the location of the top and bottom border.
The following rules change the thickness and the initial color of the borders
The following rules change the timing and the rotation.
And lastly, the following rule changes the font and border colors/opacity on hover.
And that’s it.
If you used this on one of your projects, please share a link below so we can see how you used it.
Have fun!
Well, that’s all for now. I hope you find this article useful.