Header Padding: Conditional HTML

6 months 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

Single Post

< 1 min read

Enhance WordPress Buttons

Optimize your WordPress site with these CSS tweaks. Elevate button aesthetics and code block readability for a better user experience

Read more

Post Widget

2 min read

How to Make Post Widget’s White Space Clickable (+Popup)

Go to Dashboard > Elementor > Custom Code. And then add this code to make the whole space/box/card of the

Read more

Image

< 1 min read

Crop Image To Ratio

To crop image based on ratio, on Elementor’s Image Widget add this CSS: 16:9 Landscape CSS 9:16 Portrait CSS

Read more

Header

< 1 min read

Change Color of Header and Show-Hide Elements On Scroll

Useful for transparent headers. IMPORTANT Under ‘Motion Effect’ settings, below ‘Offset’, you must set the ‘Effects Offset’ into ‘1’ or

Read more

See How It Works

Create better websites, faster.

Download the Entire Library

Adaptative, neutrally designed components.

Customer Service

Focus Website

Today, March 12

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.