Adding css file after all extensions css files

荒凉一梦 提交于 2021-02-10 22:00:41

问题


I am new to magento and i want to add one css file 'responsive.css' in the page.xml. But this file i want to add last of all css files including the extension's css files.

<block type="page/html_head" name="head" as="head">
  <!-- other css & js files -->
  <action method="addCss"><stylesheet>css/responsive.css</stylesheet></action>
</block>

And if i view the page source, my responsive.css file is showing before the extensions css files. So please help me how i can include at last of all css files.


回答1:


You can remove and add your responsive.css again in your page.xml. Be sure to do that after all other css files have been added:

<?xml version="1.0"?>
<layout>
    <default>
        <reference name="head">
            <!-- ... add your other css files ... -->
            <action method="removeItem"><type>responsive_css</type><name>css/responsive.css</name></action>
            <action method="addItem"><type>responsive_css</type><name>css/responsive.css</name></action>
        </reference>
    </default>
</layout>



回答2:


I did a quick google search and found the magento stack exchange website and a brilliant answer there that seems like it would work for you: https://magento.stackexchange.com/questions/12150/overwriting-a-css-style

  1. One way to combat this is, instead of using page.xml, to put the declaration in local.xml of your theme's layout folder. This will be loaded last and therefore your css overrides will come last.
  2. Another way to handle this is to create a custom layout file and reference it from a local module's config.xml
  3. Edit the original css file at the bottom to override its styles

See the post above for more information on this list of fixes. Basically you're looking for ways to insert your css code after the code you want to override so you can avoid using !important declarations.




回答3:


try

  <action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>


来源:https://stackoverflow.com/questions/27752533/adding-css-file-after-all-extensions-css-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!