<h5 style="color:red;">系统学习magento二次开发,推荐小册:<a style="color:blue;" href="https://www.maxiaoke.com/manual/magento_cn_dev.html" target="_blank">《Magento中文全栈二次开发 》</a></h5> <div class="image-container"> <p> <a style="color:blue;" href="https://www.maxiaoke.com/manual/magento_cn_dev.html" target="_blank"> <img src="https://www.maxiaoke.com/uploads/images/20230218/bb9c82995c24d1105676e02f373755f5.jpg" alt="Magento中文全栈二次开发"> </a> </p> </div> <div class="text-container" style="font-size:14px; color:#888"> <p>本小册面向Magento2以上版本,书代码及示例兼容magento2.0-2.4版本。涵盖了magento前端开发,后端开发,magento2主题,magento2重写,magento2 layout,magento2控制器,magento2 block等相关内容,带领您成为magento开发技术专家。</p> </div> <hr><p>在 Magento 2 中,使用 LESS 作为默认的 CSS 预处理器。以下是 Magento 2 中 LESS 编码标准的一些指导:</p><ol style="border: 0px solid rgb(217, 217, 227); box-sizing: border-box; --tw-border-spacing-x:0; --tw-border-spacing-y:0; --tw-translate-x:0; --tw-translate-y:0; --tw-rotate:0; --tw-skew-x:0; --tw-skew-y:0; --tw-scale-x:1; --tw-scale-y:1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness:proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width:0px; --tw-ring-offset-color:#fff; --tw-ring-color:rgba(59,130,246,0.5); --tw-ring-offset-shadow:0 0 transparent; --tw-ring-shadow:0 0 transparent; --tw-shadow:0 0 transparent; --tw-shadow-colored:0 0 transparent; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; list-style-position: initial; list-style-image: initial; margin-top: 1.25em; margin-bottom: 1.25em; padding: 0px 0px 0px 1rem; counter-reset: item 0; display: flex; flex-direction: column; color: rgb(55, 65, 81); font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; white-space: pre-wrap; background-color: rgb(247, 247, 248);" class=" list-paddingleft-2"><li><p>变量名使用小写字母和下划线(_)命名法,如 $primary-color。</p></li><li><p>类名和 ID 名称应使用短横线(-)命名法,如 .block-wrapper 和 #main-content。</p></li><li><p>所有属性名称和属性值应使用小写字母,如 font-size: 14px;。</p></li><li><p>使用 rem 作为基础单位来定义字体大小、间距、宽度等,如 font-size: 1.2rem;。</p></li><li><p>在声明多个属性时,使用缩进来提高代码的可读性。</p></li><li><p>使用变量来存储颜色、字体、间距等常用值,并在需要时引用变量。</p></li><li><p>使用 Mixin 来重用常用的样式代码,如:</p></li></ol><pre>.button { border-radius: 4px; padding: 12px 24px; } .button-primary { .button; background-color: $primary-color; color: #fff; } .button-secondary { .button; background-color: $secondary-color; color: #fff; }</pre><p>在上面的示例中,.button Mixin 定义了按钮的基本样式,.button-primary 和 .button-secondary 类分别使用 .button Mixin 来定义主要按钮和次要按钮的样式。</p><p>使用媒体查询来定义响应式设计,如:</p><pre>@media only screen and (max-width: 768px) { .header { height: 60px; } }</pre><p>在上面的示例中,.header 类在窗口宽度小于 768px 时会被调整为 60px 高。</p><p>以上是 Magento 2 中 LESS 编码标准的一些指导。使用这些指导,您可以编写更清晰、更易于维护的 LESS 代码。</p><p><br/></p>