使用Bootstrap CDN和DRUPAL

时间:2014-06-18 07:08:39

标签: twitter-bootstrap drupal

您好我正在使用Bootstrap和Drupal。我已经安装了由Drupal提供的bootstrap subtheme,但是如果我使用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.

3 个答案:

答案 0 :(得分:1)

我创建了一个名为'custom.css'的文件,并将其放在我的bootstrap子主题的'css'目录中。

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

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

启动网络检查员后发现我在'custom.css'中的自定义类已正确应用。

答案 1 :(得分:0)

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

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

答案 2 :(得分:0)

此问题可能在几年前得到解决。使用Drupal 7.53和Bootstrap v3,我发现使用Starterkit CDN没有问题。

我通过覆盖入门套件的css进行了测试,但它确实有用。

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

相关问题