Solved

Combine CSS

Posted on 2011-09-29
5
201 Views
Last Modified: 2012-05-12
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
Comment
Question by:rgranlund
5 Comments
 
LVL 15

Accepted Solution

by:
Eyal earned 500 total points
ID: 36817714
@import url("base.css");
0
 
LVL 7

Author Comment

by:rgranlund
ID: 36817733
@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
 
LVL 15

Expert Comment

by:Eyal
ID: 36817748
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
 
LVL 10

Expert Comment

by:jtwcs
ID: 36817802
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
 

Expert Comment

by:anandblitz
ID: 36890176
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Index on a Table 6 25
.htaccess css/images no longer loading 4 35
Why "Mobile First"? 5 17
Bootstrap list items overlap 3 7
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question