Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #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.

    #1465883

    Hey 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,
    Rikard

    #1465906

    Hi 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 weeks, 6 days ago by biggsuccess.
    #1465914

    Hi,
    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,
    Mike

    #1465918

    Mike 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 weeks, 6 days ago by biggsuccess.
    • This reply was modified 3 weeks, 6 days ago by biggsuccess.
    #1465922

    Hi,

    .main_menu {
    	padding-top: 20px;
    }

    Best regards,
    Mike

    #1465924

    Thanks 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

    #1465929

    Hi,
    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,
    Mike

    #1465936

    1) 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 weeks, 6 days ago by biggsuccess.
    #1465938

    Hi,
    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,
    Mike

    #1465945

    You’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

    #1465947

    But 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 weeks, 6 days ago by biggsuccess.
    • This reply was modified 3 weeks, 6 days ago by biggsuccess.
    #1466002

    Hi,
    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,
    Mike

    #1466005

    That works perfectly. I can’t thank you enough for your expertise, Mike. We can close this out now.

    #1466008

    Hi,
    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

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘Bar below header and before main menu’ is closed to new replies.