Set Custom Media Query Breakpoints
It would be great if one could set custom media query breakpoints from the WP admin. Thanks!
That would be a cool feature.
In the meantime can anyone suggest the best/most sensible way to override the default breakpoints?
+1
👍
Just to understand why it is so necessary to control these settings.. Is breakpoint for Mobile it not 768px (or 1024px for tablet)?
@arielk: It's necessary to control breakpoints because they should be chosen based on the design and content, not specific device sizes (which will become outdated). More info here.
PS: Elementor is great and keeps getting better, thanks to team Pojo!
As from the last version (0.8) we're using these two primary breakpoints: A. 768px and below for mobile. B. 1024px and below for tablet.
I think that it covers the most devices. We prefer to keep it more simple for most users. For more customization you can always use custom CSS.
@arielk the main thing that I think is needed here is the ability to control when the columns collapse, and how they do so. For example I have a 4 column section that I'd like to collapse to 2 columns at around 1024px, and then to 1 column at around 600px. Currently it just gets squeezed down until it drops to 1 column at 768px, this doesn't work as well as it could.
The new media based padding and margins are excellent, thank you for that addition. But greater control of column collapse would make a huge difference. @hybridvision is right on the money, MQ's aren't about screen size as much as they are about content. Also there aren't actually 3 prescribed screen sizes, there are hundreds of device sizes and it's important to have some control of layout no matter what.
Elementor is a great tool, and the improvements are coming think and fast, thank you for that.
... o.k. so you had landscape view and it 'wasnt helpful' - dont know who decided that, but this was helpful indeed for me to follow the demands/request of the clients.
everything else to custom previews or breakpoints is already mentioned above, and that does matter as you have to 'fiddle' about the right way of responsiveness on about every new site (or sometimes page). so dont let that vanish out of sight!
it may be a solution for average users to keep it as simple as possible (which is a good point), but in my opinion there should be a way for the advanced ones (or designers) to deal with custom settings (or even better for some things: global settings for the end user). maybe put that into a pro version if you want to - i'll buy it.
I would like to suggest at least allowing adjustment to existing default breakpoints in Elementor.
Elementor works with a user's theme, and it's the theme's responsive breakpoints (if any) that determine the display of things like headers, footers, etc. that Elementor doesn't control.
When the breakpoint of the theme is different from Elementor's breakpoint, the page behaves oddly on resizing. More importantly, Elementor widgets and theme elements don't coordinate properly, so a user without css experience will discover that their responsive settings aren't working and have no way to fix it.
For example, a site built with the Generate Press theme will have a mobile max-width breakpoint at 768px, while Elementor's mobile max-width is at 767px and tablet min-width is at 768px. In an iPad in portrait mode, any theme elements set for mobile-only will be on, but any Elementor elements set for mobile-only will be off.
All an average user would know is that they selected certain things to appear on mobile in their theme, and other things to appear on mobile (and not tablet) in Elementor, and it doesn't work.
An advanced setting in Elementor would help average users make Elementor work more seamlessly with their chosen theme's responsive settings, without having to ask for help and learning about custom css.
This feature should definitely be implemented. Anyway, how to override for now?
To set a custom break point, you would use CSS and add a class in the advanced settings or use the filters to make your own setting. Make sure your CSS comes after Elementor's CSS.
Add a class to the section with columns custom-break-point-width-1024
Then add your own CSS after (I use the elementor/frontend/after_enqueue_styles) hook.
@media (max-width: 1024px) {
.elementor-inner .custom-break-point-width-1024 .elementor-row {
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.elementor-inner .elementor-reverse-mobile.custom-break-point-width-1024 > .elementor-container > .elementor-row {
-webkit-box-orient: vertical;
-webkit-box-direction: reverse;
-webkit-flex-direction: column-reverse;
-ms-flex-direction: column-reverse;
flex-direction: column-reverse;
}
.elementor-inner .custom-break-point-width-1024 .elementor-column {
width: 100%
}
}
@carasmo this is interesting, thank you. The elementor/frontend/after_enqueue_styles hook is not documented yet, but I can see it in frontend.php, in enqueue_styles() function. Thank you. Though, there are no filters in /includes/responsive.php.
Anyway, for now, one can override like suggested.
I found elementor/frontend/after_enqueue_styles by reading the readme.txt https://github.com/pojome/elementor/search?utf8=%E2%9C%93&q=elementor%2Ffrontend%2Fafter_enqueue_styles&type=
You're right, there is no filter. I should have written the elementor/element/before_section_end action, which allows you to add your own control and then you add your css.
/*
* Add Custom Control
* https://github.com/pojome/elementor/blob/master/docs/content/hooks/php-hooks.md#elementorelementbefore_section_end
*
* https://github.com/pojome/elementor/issues/26
*/
function themeprefix_elementor_controls( $section, $section_id, $args ) {
if( $section->get_name() == 'section' && $section_id == 'section_layout' ) :
$section->add_control(
'themeprefix_custom_breakpoint',
[
'label' => __( 'Custom Column Breakpoint', 'text-domain' ),
'description' => __( 'At what width do the columns stack and become 100% wide? Under 768px, use custom CSS', 'text-domain' ),
'type' => Elementor\Controls_Manager::SELECT,
'default' => '',
'options' => array(
'' => ' ',
'width-900' => '900px',
'width-1000' => '1000px',
'width-1024' => '1024px',
'width-1200' => '1200px',
),
'prefix_class' => 'custom-break-point-',
'label_block' => true,
]
);
endif; // Section Custom Controls
}
add_action( 'elementor/element/before_section_end' , 'themeprefix_elementor_controls', 10, 3 );
Good, but this seems about specific sections, not global. Also, we really would need a filter to modify core breakpoints, so the user can then style elements by himself based on global presetted breakpoints. The solutions above can help a developer, but don't allow the end user to take full avantage of the Elementor Editor.
Anyway, it's another way, for now, so thank you. Again, I hope developers will simply add some filter to responsive.php :)
Please implement custom breakpoints in the frontend! We are a non profit group of students, managing the website of our dormitory and we have the policy that we can not spend any money on software, so we can not buy the pro version to get custom css.
But a frontend implementation would also be better for pro users, because it is much easier, faster and more flexible.
@nicolasblume they could implement it in backoffice, but anyway, what I was asking here is to add filters to responsive.php, and this would not be a Pro feature, it would just be a global one and you could then use it to add your own breakpoints via php.
So in any way, no frontend would be implied, nor the Pro version.
@carasmo Thank you so much for the CSS above. That helped me tremendously today. I wish I knew how to implement the custom control code you have above. That would be even more awesome. But you've saved my day with that CSS.
It would be immensely useful to have the ability deal with landscape mode. That "gray area" between 768 and 1024 (1080 for me actually) is a cesspool for some designs, and not so bad for others. But those edge cases really need some ability to control landscape tablet mode.
+1 for me too It is essential for working with different themes or the layouts based rather on the design and content, than on specific device sizes.
Extra breakpoint between 0 and 768px (quite a huge area to have all the content in one single column) would be nice too, but it's a different issue.
@black-eye yes, but i don't think it would be so difficult adding a couple more breakpoints, once done what discussed above. So I think this one it's a good feature request to add. To me, this would be perfect:
- 6 manageble breakpoints
- 3 of the 6 would be the defaults for Elementor (small, medium, large)
- 3 of the 6 would be optional auxiliary ones, meaning they would be totally up to the developer
I generally use these in my projects:
small small-aux medium medium-aux large xlarge
I then always manage at least small, medium, and large. Occasionally, I make use of the others. Small-aux and medium-aux do end to the same values of the small and medium ends, but do start after. For example:
small: 0-640 small-aux: 480-640 // same end of small medium: 640-1080 medium-aux: 840-1080 // same end of medium
Anyway, to the devs: 6 manageble breakpoints, that's all, that's what we all want! :)