【发布时间】:2015-06-28 09:12:27
【问题描述】:
我创建了一个响应式 Bartik 的子主题,我需要在不触及原始主题的情况下减小侧边栏的宽度:
原文:
@media all and (min-width: 851px) {
.
.
.
#sidebar-first {
width: 25%;
margin-left: -100%; /* LTR */
}
#sidebar-second {
width: 25%;
margin-left: -25%; /* LTR */
clear: none;
}
.
.
.
}
子主题中的 CSS:
/* Raj: To reduce the width of the sidebar: */
@media all and (min-width: 851px)
{
#sidebar-first {
width: 18% !important;
margin-left: -92% !important; /* LTR */
}
#sidebar-second {
width: 18%;
margin-left: -32%; /* LTR */
clear: none;
}
}
令我惊讶的是,原来的 CSS 正在生效。除了媒体查询我可以覆盖的任何其他 css 属性。如果我在原始 css 文件本身中将 25% 更改为 18% 并将 -100% 更改为 -92%,我将获得所需的结果,但我无法弄清楚如何在另一个 css 文件中覆盖这些值。
我试图用谷歌搜索,但我得到的只是媒体查询中的优先级,而没有关于覆盖。
编辑: 我已经使用子主题的 .info 文件添加了新的 CSS 文件。以下是各个 .info 文件的内容。我遵循了一个drupal文档来创建子主题。但是,我真的不觉得这是 Drupal 架构中的问题,但是覆盖 CSS 媒体查询可能必须以不同的方式完成,这个结论的原因是因为 custom.css 文件中的任何其他 css 属性都在渲染,除了覆盖媒体查询。
原文:
name = Responsive Bartik Tiles
description = Tile based flexible, recolorable theme with many regions and a responsive, mobile-first layout.
version = VERSION
core = 7.x
stylesheets[all][] = css/layout.css
stylesheets[all][] = css/style.css
stylesheets[all][] = css/colors.css
stylesheets[print][] = css/print.css
scripts[] = js/collapsible-menu.js
regions[header] = Header
regions[help] = Help
regions[page_top] = Page top
regions[page_bottom] = Page bottom
regions[highlighted] = Highlighted
regions[featured] = Featured
regions[content] = Content
regions[sidebar_first] = Sidebar first
regions[sidebar_second] = Sidebar second
regions[triptych_first] = Triptych first
regions[triptych_middle] = Triptych middle
regions[triptych_last] = Triptych last
regions[footer_firstcolumn] = Footer first column
regions[footer_secondcolumn] = Footer second column
regions[footer_thirdcolumn] = Footer third column
regions[footer_fourthcolumn] = Footer fourth column
regions[footer] = Footer
settings[shortcut_module_link] = 0
; Information added by Drupal.org packaging script on 2014-10-15
version = "7.x-1.0"
core = "7.x"
project = "responsive_bartik_tiles"
datestamp = "1413392482"
子主题:
name = Indian Snakes Responsive Bartik Tiles
description = Indian Snakes Tile based flexible, recolorable theme with many regions and a responsive, mobile-first layout.
version = VERSION
core = 7.x
base theme = responsive_bartik_tiles
stylesheets[all][] = css/layout.css
stylesheets[all][] = css/style.css
stylesheets[all][] = css/colors.css
stylesheets[print][] = css/print.css
stylesheets[all][] = css/custom.css
scripts[] = js/collapsible-menu.js
regions[header] = Header
regions[help] = Help
regions[page_top] = Page top
regions[page_bottom] = Page bottom
regions[highlighted] = Highlighted
regions[featured] = Featured
regions[content] = Content
regions[sidebar_first] = Sidebar first
regions[sidebar_second] = Sidebar second
regions[triptych_first] = Triptych first
regions[triptych_middle] = Triptych middle
regions[triptych_last] = Triptych last
regions[footer_firstcolumn] = Footer first column
regions[footer_secondcolumn] = Footer second column
regions[footer_thirdcolumn] = Footer third column
regions[footer_fourthcolumn] = Footer fourth column
regions[footer] = Footer
settings[shortcut_module_link] = 0
; Information added by Drupal.org packaging script on 2014-10-15
version = "7.x-1.0"
core = "7.x"
project = "responsive_bartik_tiles"
datestamp = "1413392482"
唯一的区别是增加了一行-
stylesheets[all][] = css/custom.css
在子主题的 .info 文件中。
【问题讨论】:
-
尝试在head标签
<style>/* Raj: To reduce the width of the sidebar: */ @media all and (min-width: 851px)...</style>中添加CSS代码 -
这意味着您的子主题的 CSS 媒体查询已加载之前父主题的 CSS。
标签: html css drupal drupal-theming