gpt4 book ai didi

Magento 2 - 如何通过 referenceContainer 或其他方式更改 htmlClass、htmlId 属性?

转载 作者:行者123 更新时间:2023-12-04 22:19:45 25 4
gpt4 key购买 nike

In magento 2 Frontend developer guide ,我读过:

Certain attributes, like htmlClass, htmlId, label attributes can be changed in extending layouts



我想更改 1column.xml 中定义的容器的 htmlClass。你能告诉我如何通过 referenceContainer 或其他方式做到这一点吗?

我用过:(html_class 和 htmlClass)
<arguments>
<argument name="html_class" xsi:type="string">sm-page-header</argument>
</arguments>

但不受影响

谢谢!

最佳答案

如果使用以下代码在 xml 中声明容器:

<container name="my.container" htmlTag="div" htmlClass="old-class">
<...>
</container>

您可以通过将以下代码放置在扩展布局文件中的某个位置来简单地覆盖 css-class:
<referenceContainer name="my.container" htmlClass="new-class" />

关于Magento 2 - 如何通过 referenceContainer 或其他方式更改 htmlClass、htmlId 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34216138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com