Tagged: http://staging2.advancedinnergy.com/wp-content/uploads/2024/08/Screenshot-bar-below-header.png
-
AuthorPosts
-
August 30, 2024 at 9:05 pm #1465839
My client would like a tagline in a colored bar in between the header and the main menu. They want it to show on every page like the header and menu.
Is this possible? I have an image link below to see what they envision.
I am using a child theme which we’ve already created a header widget for to have buttons on the right side of the header.
Thanks for your assistance.
August 31, 2024 at 1:13 pm #1465883Hey biggsuccess,
I can’t see any image attached to your message, but you can select to show a bar above the header under Enfold->Header->Extra Elements.
Best regards,
RikardAugust 31, 2024 at 6:00 pm #1465906Hi Rikard – I’ve pasted the image link again and should work now.
We are already using the secondary bar above to display their phone number.
As you’ll see in the image, they want to see if we can add a banner below the header and above the main menu that shows a tagline.
- This reply was modified 3 months, 2 weeks ago by biggsuccess.
August 31, 2024 at 7:44 pm #1465914Hi,
Thanks for your screenshot, try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:function banner_below_the_header_and_above_the_main_menu() { ?> <script> // Create the new div element const newDiv = document.createElement('div'); // Set the text content newDiv.textContent = 'The Most Comprehensive Alternative Wellness Experience In The Midwest'; // Set the style properties newDiv.style.backgroundColor = 'gray'; newDiv.style.color = 'white'; newDiv.style.fontSize = '22px'; newDiv.style.padding = '10px'; // Add the flexbox properties newDiv.style.display = 'flex'; newDiv.style.justifyContent = 'center'; newDiv.style.order = '4'; newDiv.style.flexBasis = '100%'; // Find the element with class "main_menu" const mainMenu = document.querySelector('.main_menu'); // Insert the new div before the main_menu if (mainMenu) { mainMenu.parentNode.insertBefore(newDiv, mainMenu); } </script> <?php } add_action( 'wp_footer', 'banner_below_the_header_and_above_the_main_menu', 99 );
Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
See the expected results in the screenshot below.Best regards,
MikeAugust 31, 2024 at 8:33 pm #1465918Mike that is amazing! Now if I want to add a little more padding between the bottom of the banner and the top of the menu what css should I use?
Also – anything I can do to make that a little nicer on mobile view?
And what I can do to prevent the top of the slider element below the menu on mobile view from not being cut off
- This reply was modified 3 months, 2 weeks ago by biggsuccess.
- This reply was modified 3 months, 2 weeks ago by biggsuccess.
August 31, 2024 at 8:40 pm #1465922August 31, 2024 at 8:47 pm #1465924Thanks Mike – I edited in a couple other issues:
1) Is there anything I can do to make the banner look a little nicer on mobile view?
2) And what I can do to prevent the top of the slider element below the menu on mobile view from not being cut off
August 31, 2024 at 9:00 pm #1465929Hi,
I’m not sure what would be “nicer on mobile view”
But this added element is covering your LayerSlider so you could hide this on mobile or add more top margin/padding to your LayerSlider to push it down.Best regards,
MikeAugust 31, 2024 at 9:09 pm #14659361) I was hoping there may be some CSS for mobile view of the banner – to look as it does on desktop and not collapse into a box with stacked text. If that isn’t possible that’s fine too.
2) Could you please assist me with a CSS suggestion for top margin/padding for the LayerSlider
I appreciate your help
- This reply was modified 3 months, 2 weeks ago by biggsuccess.
August 31, 2024 at 9:41 pm #1465938Hi,
Let’s try adding a custom class “custom-banner” to the div to better manage future changes, and change the font size for mobile from 22px to 12px, this will make the text on mobile closer to what you want, you can even try smaller if you find 12px still to big.
This is the new script:function custom_banner_below_the_header_and_above_the_main_menu() { ?> <script> // Create the new div element const newDiv = document.createElement('div'); // Set a class for the new div newDiv.className = 'custom-banner'; // Set the text content newDiv.textContent = 'The Most Comprehensive Alternative Wellness Experience In The Midwest'; // Set the style properties for screens above 768px newDiv.style.backgroundColor = 'gray'; newDiv.style.color = 'white'; newDiv.style.fontSize = '22px'; // Default font size for larger screens newDiv.style.padding = '10px'; // Add the flexbox properties newDiv.style.display = 'flex'; newDiv.style.justifyContent = 'center'; newDiv.style.order = '4'; newDiv.style.flexBasis = '100%'; // Find the element with class "main_menu" const mainMenu = document.querySelector('.main_menu'); // Insert the new div before the main_menu if (mainMenu) { mainMenu.parentNode.insertBefore(newDiv, mainMenu); } // Adjust styles based on screen width function adjustStyles() { if (window.innerWidth < 768) { newDiv.style.fontSize = '12px'; // Font size for screens below 768px } else { newDiv.style.fontSize = '22px'; // Font size for screens 768px and above } } // Initial adjustment adjustStyles(); // Adjust on window resize window.addEventListener('resize', adjustStyles); </script> <?php } add_action( 'wp_footer', 'custom_banner_below_the_header_and_above_the_main_menu', 99 );
Please give this a try.
Best regards,
MikeAugust 31, 2024 at 10:51 pm #1465945You’ve done it again. That looks perfect everywhere and I appreciate the new custom class too!
Thank you so much for your help with this. My client will be VERY happy :D
August 31, 2024 at 10:59 pm #1465947But I do appear to need one more bit of help with CSS –
What can I do to add some padding as the element is now overlapping the top of some pages a bit – see one example below.
FYI this is desktop view only. I have this issue via mobile taken care of using:
@media only screen and (max-width: 430px) {
.html_header_top.html_header_sticky #top #wrap_all #main {
padding-top: 282px !important;
}
}@media only screen and (max-width: 767px) and (orientation: landscape) {
.responsive #top #wrap_all #main {
padding-top: 259px !important;
}
}@media only screen and (max-width: 690px) and (orientation: landscape){
.responsive #top #wrap_all #main {
padding-top: 282px !important;
}
}- This reply was modified 3 months, 2 weeks ago by biggsuccess.
- This reply was modified 3 months, 2 weeks ago by biggsuccess.
September 1, 2024 at 5:13 pm #1466002Hi,
For desktop this seems to work for me:@media only screen and (min-width: 768px) { .html_header_top.html_header_sticky #top #wrap_all #main { padding-top: 290px; } }
Best regards,
MikeSeptember 1, 2024 at 6:31 pm #1466005That works perfectly. I can’t thank you enough for your expertise, Mike. We can close this out now.
September 1, 2024 at 7:08 pm #1466008Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Bar below header and before main menu’ is closed to new replies.