2017-06-21 327 views
0

我在Shopify中創建了一個名爲Slideshow with Button的新主題部分。我一直在添加功能,允許客戶端添加自己的按鈕文本成功,但現在嘗試創建功能來定製按鈕的背景顏色時卡住了。主要的問題是液體代碼沒有填充CSS。下面是我在我的液體部分文件現在:使用Shopify的Liquid在自定義主題部分中創建自定義按鈕背景色。

   {% if block.settings.link != blank %} 
      <a href="{{ block.settings.link }}" class="dynamic_button_link"> 
      {% endif %} 

      <style> 
       .dynamic-button { 
        background-color:{{ section.settings.button_bg_color }}!important; 
        z-index:999; 
       } 
      </style> 

       {% unless block.settings.button_text == blank %} 
       <div class='dynamic-button'>{{ block.settings.button_text | escape }}</div> 
       {% endunless %} 

       {% if block.settings.link != blank %} 
       </a> 
       {% endif %} 

  { 
      "type": "color", 
      "id": "button_bg_color", 
      "label": "Background color", 
      "default": "#ffffff" 
      }, 

的顏色選取正確顯示出來,但是......

enter image description here

顯然,動態色彩類型沒有按預期填充CSS ...

enter image description here

任何援助將不勝感激。謝謝。

回答

1

如果這個{{ section.settings.button_bg_color }}是這個{{ block.settings.button_bg_color }}