You can create a multimedia query rule programmatically - activate by measuring the width of your menu (using js / jQuery):
document.querySelector('style').textContent += "@media screen and (min-width:400px) { div { color: red; }}"
Requests in the media are not intended to be activated when the width of the element on the page or screen changes, although this is due to changes in the viewport / window itself and other factors. (Full list can be found here )
You have not posted your menu code so that it is difficult to understand the “wrapping” you are experiencing, but if your horizontal menu is “turned off”, you might be better off setting the menu as a percentage (%) of the width of the viewport and using a series of media queries that re-draw menus, as well as modify / delete children, etc. at certain screen widths .
source share