Header Padding: Conditional HTML

1 year ago

< 1 min read

Posted by:

Focus

Subscribe to newsletter

By subscribing you agree to with our Privacy Policy.

Share

If you want to have conditional padding for your header, give your header the CSS class .mainheader and add an HTML widget to your page (not the header). Paste the following code into your HTML widget:

<script>
function adjustMainHeaderPadding() {
    if (window.innerWidth <= 767) {
        var mainHeader = document.querySelector('.mainheader');
        if (mainHeader) {
            mainHeader.style.paddingLeft = '15px';
            mainHeader.style.paddingRight = '15px';
        }
    }
}

// Run the function when the page loads
window.addEventListener('load', adjustMainHeaderPadding);

// Also run the function when the window is resized
window.addEventListener('resize', adjustMainHeaderPadding);
</script>

Read more

Text Widget

2 min read

Perfecting WordPress Text Content Formatting

If you want to have slightly better but very satisfying content formatting for those who understand content formatting, use the

Read more

Effect

< 1 min read

Blur Effect CSS

Learn how this simple blur effect addition can transform your website’s visual appeal, creating a sleek and modern look that

Read more

Container

< 1 min read

Hide Scroll Bar On ‘Overflow: Auto’ Container

Add this following CSS code to the container: selector {-ms-overflow-style: none; /* IE and Edge / scrollbar-width: none; / Firefox

Read more

Single Post

2 min read

Hiding “Previous Post” Navigation in Elementor with Custom CSS

Hi, there! I’ll share some quick tips on how to change the appearance of article navigation on your Elementor website.

Read more

See How It Works

Create better websites, faster.

Download the Entire Library

Adaptative, neutrally designed components.

Customer Service

Focus Website

Today, October 15

Hi, there 👋

How can I help you?

Start Chat with:

We use cookie to improve your experience on our site. By using our site you consent cookies.