我创建响应Bartik的子主题,我需要减少侧边栏的宽度,而不触及原来的主题:重写媒体查询特定宽度 - CSS
原文:
@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 Media查询可能需要以不同的方式完成,这个结论的原因是因为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文件
。
尝试增加你的头标记'' – GLES
这意味着,你的子主题的CSS媒体查询已加载** BEFORE **父主题的CSS。 – odedta