Magento2 Layout move element only for desktop view?
-
01-01-2021 - |
Pergunta
I'm trying to adapt the Luma Theme for my needs and move some elements in layout.
I add a default.xml
file in my Child Theme and add those lines :
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<move element="minicart" destination="header.container" before="-" />
<referenceBlock name="top.search" remove="true"/>
</body>
</page>
The minicart
is now on the header container
but is there a directive to apply these changes only for Desktop and not for Mobile view ?
Solução
XML layout files do not care about platform or screen size. You'll have to use CSS and JS to get the style you're going for.
Documentation about moving elements with JS
The
responsive.js
script implements specific responsive functions for the Blank and Luma themes.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange