0
Welcome Guest! Login
0 items Join Now

SOLVED how to make custom css to load last?

  • SOLVED how to make custom css to load last?

    Posted 11 years 3 months ago
    • Hi there,

      Is there a way to ensure that the custom css file is being loaded last?
      I am normally creating a templatename-custom.css file that loads last until I am adding further modules such as e.g. rokajaxsearch, roksprocket which are being loaded after custom.css. Hence any changes in the custom.css file will not apply since their are loaded later.
      <link rel="stylesheet" href="/panatecs2/templates/rt_chapelco/css/rt_chapelco-custom.css" type="text/css" />
        <link rel="stylesheet" href="/panatecs2/modules/mod_rokajaxsearch/css/rokajaxsearch.css" type="text/css" />
        <link rel="stylesheet" href="/panatecs2/modules/mod_rokajaxsearch/themes/light/rokajaxsearch-theme.css" type="text/css" />

      The order of the above stylesheets needs to be reversed with rt_chapelco-custom.css always loading last.

      I am using Chapelco and developing the site under www.mc4-it.com/panatecs2/en/ .

      Thanks,
      Matthias
    • Last Edit: 11 years 3 months ago by Matthias Raab.
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: SOLVED how to make custom css to load last?

    Posted 11 years 3 months ago
    • Never rely on loading order of css files.
      Use CSS specificity to override other rules.
  • Re: SOLVED how to make custom css to load last?

    Posted 11 years 3 months ago
    • Thanks Henning. I know you suggested specificity in other posts. Can you point me to some practical examples? Would you simply add "!important" behind each declaration in your custom css file?
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: SOLVED how to make custom css to load last?

    Posted 11 years 3 months ago
  • Re: SOLVED how to make custom css to load last?

    Posted 11 years 3 months ago
    • Henning, that's great. Adding an ID to the body tag is exactly the kind of practical example I was after.
      Many thanks,
      Matthias
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: SOLVED how to make custom css to load last?

    Posted 11 years 3 months ago
    • it most cases its just enough to add a littlle bit of specificity.

      .dark {color: red;}
      will be override by
      div.dark {color: blue)

      etc.

Time to create page: 0.071 seconds