PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, June 30, 2022

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

 June 30, 2022     css, liquid, shopify     No comments   

Issue

I am trying to add a custom css to my shopify section. I have created a css file in asset folder called test2.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:

enter image description here

I have followed this guide:

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

But it doesn’t work. What am I doing wrong?


Solution

To add a custom CSS file to the section in shopify simply just add this at the very top of the section

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


Answered By - Adnan
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing