官术网_书友最值得收藏!

Including CSS in the block view

Developers and designers working on custom concrete5 block types can have a CSS file automatically included. In this recipe, we will automatically include a CSS file that will change our background to black.

Getting ready

We are still working with the block that was created earlier in the chapter. Please make sure that block exists, or adapt this recipe to suit your own concrete5 environment.

How to do it...

The steps for including CSS in the block view are as follows:

  1. Open your block's directory.
  2. Create a new file called view.css, if it doesn't exist.
  3. Add a rule to change the background color of the site to black:
    body {
      background: #000 !important;
    }
  4. Visit the page containing your block.
  5. The background should now be black!

How it works...

Just like it does with JavaScript, concrete5 will automatically include view.css in the page's header if it exists in your block directory. This is a great way to save some time with styles that only apply to your block.

See also

  • The Including JavaScript in block forms recipe
  • The Including JavaScript in the block view recipe
主站蜘蛛池模板: 汉川市| 城市| 化德县| 称多县| 瓦房店市| 长宁县| 渭南市| 额尔古纳市| 镇安县| 墨竹工卡县| 巴彦淖尔市| 宜州市| 天门市| 富阳市| 宜兴市| 贡嘎县| 江西省| 康保县| 合阳县| 南通市| 丹巴县| 武夷山市| 高雄县| 龙山县| 大庆市| 镇康县| 和田县| 鹤岗市| 海盐县| 新丰县| 筠连县| 桐梓县| 西乡县| 柞水县| 五指山市| 平利县| 皮山县| 静海县| 阳东县| 山东省| 偃师市|