Custom Header with Contact Info (Left) – Right (Burger) – Middle (Logo)

Description

  • custom header with contact info (left) – middle (logo) – right (burger)
  • view demo – password: abc
  • buy me a coffee

02.26c12v1

Note

  • if you use Personal/Basic Plan and can’t add Code Injection Code, message me, I will add code for you or give you new code (if you provide exact phone number, text, url)

#1. Install Code

#1.1. First, use this code to Custom CSS

:root {
    --header-btn-color: #000;
    --header-btn-font-size: 12px;
    --header-btn-border: 1px solid #000;
    --header-btn-min-height: 55px;
}
.header-burger {
    display: flex !important
}
.header--menu-open .header-menu {
    opacity: 1 !important;
    visibility: visible !important
}
.header-nav,.header-actions {
    visibility: hidden !important
}
.header-actions-custom {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}
.header-actions-custom a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 5px 15px;
    border: var(--header-btn-border) !important;
    border-radius: 0px !important;
    text-decoration: none;
    color: var(--header-btn-color) !important;
    min-height: var(--header-btn-min-height);
    background: transparent;
    box-sizing: border-box;
    gap: 8px;
    visibility: visible !important;
}
.header-actions-custom .btn-phone span {
    line-height: 1.1;
    font-size: var(--header-btn-font-size);
    text-align: left;
    color: var(--header-btn-color);
}
.header-actions-custom .btn-contact span {
    font-size: var(--header-btn-font-size);
    color: var(--header-btn-color);
}

02.26c12v1

#1.2. Next, use this code to Code Injection > Footer (or Code Injection > Header)

<!-- @tuanphan - Custom Header -->
<script>
const HEADER_BUTTONS = [
  {
    href: 'tel:4247774379',
    cls: 'btn-phone',
    content: `<i class="fas fa-phone-alt"></i><span>424-777-<br>4379</span>`
  },
  {
    href: 'https://maps.app.goo.gl/jT1dWWwLoBTNJBUz5',
    cls: 'btn-map',
    content: `<i class="fas fa-map-marker-alt"></i>`
  },
  {
    href: '/contact',
    cls: 'btn-contact',
    content: `<span>CONTACT</span>`
  }
];

document.addEventListener('DOMContentLoaded', function() {
  const targetSelector = '.header-display-desktop .header-nav';

  const checkExist = setInterval(function() {
    const targetElement = document.querySelector(targetSelector);

    if (targetElement) {
      clearInterval(checkExist);
      const oldGroup = document.querySelector('.header-actions-custom');
      if (oldGroup) oldGroup.remove();
      const headerActionGroup = document.createElement('div');
      headerActionGroup.className = 'header-actions-custom';
      headerActionGroup.style.cssText = 'display: flex !important; align-items: center; gap: 10px; margin-left: auto;';
      const commonClass = 'btn btn--border theme-btn--primary-inverse sqs-button-element--primary';
      HEADER_BUTTONS.forEach(btnData => {
        const anchor = document.createElement('a');
        anchor.className = commonClass + ' ' + btnData.cls;
        anchor.href = btnData.href;
        anchor.innerHTML = btnData.content;
        headerActionGroup.appendChild(anchor);
      });
      targetElement.appendChild(headerActionGroup);
    }
  }, 100);
});
</script>

02.26c12v1

#2. Customize

#2.1. To change button text/url, change these

const HEADER_BUTTONS = [
  {
    href: 'tel:4247774379',
    cls: 'btn-phone',
    content: `<i class="fas fa-phone-alt"></i><span>424-777-<br>4379</span>`
  },
  {
    href: 'https://maps.app.goo.gl/jT1dWWwLoBTNJBUz5',
    cls: 'btn-map',
    content: `<i class="fas fa-map-marker-alt"></i>`
  },
  {
    href: '/contact',
    cls: 'btn-contact',
    content: `<span>CONTACT</span>`
  }
];

02.26c12v1

#2.2. To change button style, change these lines

:root {
    --header-btn-color: #000;
    --header-btn-font-size: 12px;
    --header-btn-border: 1px solid #000;
    --header-btn-min-height: 55px;
}

02.26c12v1

#2.3. To make Contact Info float on right side on Other Pages, use this extra code to Custom CSS box

body:not(.homepage) {
@media screen and (min-width:768px) {
    .header-actions-custom {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}
div.header-burger {
    position: absolute;
    left: 0;
  }}}

0226c12v1

Buy me a coffee