【问题标题】:Using Bootstrap CDN with DRUPAL将引导 CDN 与 DRUPAL 一起使用
【发布时间】:2014-06-18 07:08:39
【问题描述】:

您好,我正在将 Bootstrap 与 Drupal 一起使用。我已经安装了 Drupal 提供的 bootstrap 子主题,但是如果我使用我的 style.css 来应用我的设计更改,则 bootstrap 的默认样式不会被覆盖。

有谁知道如何覆盖这些默认样式? 我用的是Bootstrap CDN,知道什么意思的朋友,在官方教程中称为方法2。

PS:

指定类或使用 !important 不起作用!

根据评论中的要求:

我使用了与本教程中所述完全相同的结构: https://drupal.org/node/1978010)

这是我的信息文件的代码:

name = Bootstrap Sub-theme
description = A Bootstrap Sub-theme.
core = 7.x
base theme = bootstrap


;;;;;;;;;;;;;;;;;;;;;
;; Regions
;;;;;;;;;;;;;;;;;;;;;

regions[navigation]     = 'Navigation'
regions[header]         = 'Top Bar'
regions[highlighted]    = 'Highlighted'
regions[help]           = 'Help'
regions[content]        = 'Content'
regions[sidebar_first]  = 'Primary'
regions[sidebar_second] = 'Secondary'
regions[footer]         = 'Footer'
regions[page_top]       = 'Page top'
regions[page_bottom]    = 'Page bottom'


;;;;;;;;;;;;;;;;;;;;;
;; Stylesheets
;;;;;;;;;;;;;;;;;;;;;

stylesheets[all][] = css/style.css


; For information on choosing the desired method, please read the Drupal
; Bootstrap sub-theme "how-to" documentation:
; https://drupal.org/node/1978010

; ;----------------------------------
; ; METHOD 1: Bootstrap Source Files
; ;----------------------------------
; 
; 
;
; ; Disable BootstrapCDN if using Bootstrap source files in your sub-theme.
; settings[bootstrap_cdn] = ''


; ;-------------------------
; ; METHOD 2: Bootstrap CDN
; ;-------------------------
;

 Method 2 uses BootstrapCDN, the only thing you might need to provide here
; is overrides to Bootstrap theme settings. Copy them here from the base theme
; to override.

【问题讨论】:

  • 你能告诉我们你的主题的结构和你的子主题的 .info 文件吗?
  • 我将代码添加到我之前的帖子中。谢谢
  • 还在寻找答案吗?任何人?请...
  • 你的样式有可能被 Bootstrap 覆盖了吗? Bootstrap 可以更直接地针对这些元素。

标签: twitter-bootstrap drupal


【解决方案1】:

我创建了一个名为“custom.css”的文件并将其放在我的引导子主题的“css”目录中。

然后我在我的信息文件中添加了一行,阅读

stylesheets[all][] = css/custom.css

启动网络检查器显示我在“custom.css”中的自定义类已正确应用。

【讨论】:

    【解决方案2】:

    几天前我遇到了同样的问题,我修复了模板预处理功能。只需将以下函数放在你的 template.php 中

    function YOUR_THEME_preprocess_html(&$variables) {
      drupal_add_css('/PATH_TO_THEME/custom-style.css');
    }
    

    【讨论】:

      【解决方案3】:

      这个问题可能在几年前就解决了。使用 Drupal 7.53 和 Bootstrap v3,我发现使用 Starterkit CDN 没有问题。

      我通过覆盖 starterkit 的 css 对此进行了测试,它可以工作。

      由于它有效,不再需要通过模板预处理函数调用css来覆盖Bootstrap的默认样式。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-11-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-10-24
        相关资源
        最近更新 更多