Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

Combine CSS

I have a website that uses 5 different CSS files.  There are many reasons for this.

Is there a way to combine them all into one link?  I dont/cant put all the styles into one CSS but in the head I would like to link one file and then that one file have all 5 of the style sheets in it.

How do I do this correctly?
0
rgranlund
Asked:
rgranlund
1 Solution
 
EyalCommented:
@import url("base.css");
0
 
rgranlundAuthor Commented:
@Eyal... then how do I write the base css?

@importurl(css-1.css);
@importurl(css-2.css);
@importurl(css-3.css);
@importurl(css-4.css);

is that correct?
0
 
EyalCommented:
yes, but pay attention the browser will download 5 files and not 1 but in your html it will include only the base css
0
 
jtwcsCommented:
Eyal is correct but you also need to have the @import calls first in the main css file.  Meaning, they must come before any other declarations.

http://www.w3.org/TR/CSS2/cascade.html#at-import
0
 
anandblitzCommented:
Try this:


<target name="css" description="Concatenate CSS source files">
    <loadtasks assembly="${NAntContrib}\NAnt.Contrib.Tasks.dll" />
    <echo message="Building ${BuildDir}\${CssFileLocation}\style.css" />
    <concat destfile="${BuildDir}\${CssFileLocation}\style.css" append="true">
      <fileset>
        <include name="${BuildDir}\${CssFileLocation}\*.css" />
        <exclude name ="${BuildDir}\${CssFileLocation}\default.css"/>
      </fileset>
    </concat>
    <echo message="${BuildDir}\${CssFileLocation}\style.css built." />
    <echo message="delete other files except style.css" />
    <delete>
      <fileset>
        <include name="${BuildDir}\${CssFileLocation}\*.css"/>
        <exclude name="${BuildDir}\${CssFileLocation}\style.css"/>
        <exclude name ="${BuildDir}\${CssFileLocation}\default.css"/>
      </fileset>
    </delete>
    <echo message="delete other files except style.css is done" />
  </target>
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now