Conditions for Screen Sizes

Be great to use conditions to hide/show elements based on screen size - in particular with headers on tablet / mobile / desktop when you need to move things about and even display things very differently - it would be great to remove as much html as possible without just CSS hiding it?

1 Like

I’m afraid the condition by any builders can’t detect screen size.

Hmm, fair OK.

No better way this could be done?

Only PHP can hide the HTML output.

So, to hide those elements(not html) on mobile, you can only achieve it with breakpoints styling. With :nth-child

Cheers Jornes. I use that already dude, I was meaning more like when your menu is completely different on different screen sizes.

Fully support the idea! :+1: Excessive html that is hidden via display: none in templates is unnecessary. This is a bad practice, especially for seo. Why would search engine crawlers download useless code? If you have a lot of such code, you will have unobvious problems.

1 Like

Just a simple example but something like this with PHP - but built into a nice UI within Bricks say? :pray:

<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];

if (preg_match('/mobile/i', $user_agent)) {
    echo '<div class="mobile-content">This is content for mobile devices.</div>';
} else {
    echo '<div class="desktop-content">This is content for desktop devices.</div>';
}
?>