简体   繁体   English

如何将自定义 css 添加到 shopify 中的部分

[英]How to add custom css to section in shopify

I am trying to add a custom css to my shopify section.我正在尝试将自定义 css 添加到我的 shopify 部分。 I have created a css file in asset folder called test2.css:我在名为 test2.css 的资产文件夹中创建了一个 css 文件:

.body {
  background-color: lightgrey;
  color: blue;
}

.h1 {
  color: white;
}

And on top of my liquid file I have added this code:在我的液体文件之上,我添加了这段代码:

<div class="page-width {{ section.settings.section_css_class }}"> 

And below in the liquid file:在下面的液体文件中:

{

"type": "text",
    "id": "section_css_class",
    "label": {
      "en": "Section CSS Class"
    },
    "default": {
      "en": "Type your own CSS class"
    }
  },

In my section I got this input box:在我的部分中,我得到了这个输入框:

在此处输入图像描述

I have followed this guide:我遵循了本指南:

https://www.ecommercethesis.com/how-to-add-css-class-to-a-section-in-shopify/ https://www.ecommercethesis.com/how-to-add-css-class-to-a-section-in-shopify/

But it doesn't work.但它不起作用。 What am I doing wrong?我究竟做错了什么?

To add a custom CSS file to the section in shopify simply just add this at the very top of the section要将自定义 CSS 文件添加到 shopify 中的部分,只需将其添加到该部分的最顶部

<link rel="stylesheet" href="{{ 'test2.css' | asset_url }}">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM