URL path in CSS

Source: Internet
Author: User
In CSS, the URL syntax is used to specify background-image or other referenced files, such:
. Mainheader {
Height: 52px;
Background-image: URL (../images/mainheader_top_bj.gif );
Background-repeat: Repeat-X;
Background-position: top;
}
1. Type 1 of background-image:
In actual applications, CSS is often written into style files, and put into a special directory, put the image into a special image directory, and the actually used aspx file is in another directory, suppose there is a directory for practical application:
---- Root
---- Images
--Mainheader_top_bj.gif
---- CSS
--A1.css
---- Ff. aspx

Among them, ff.aspxis introduced to a1.css, and a1.css contains. mainheader, as shown inArticleUse the mainheader_top_bj.gif image in images.
The URL should be ff.aspx, or a1.css?
After testing, we found that the plugin is based on a1.css (that is, the CSS file), whether it is used in HTML files or on the Asp.net website.

2. behavior Class 1
behavior used by IE: URL (xxx/XXXXX. HTC) for HTML components. At this time, the HTC file path specified in the URL is relative to the directory where HTML is located, as shown below:
---- root
---- images
--mainheader_top_bj.gif
-- iepngfix. HTC
---- CSS
--a1.css
---- pub1
-- frm1.aspx
---- ff. aspx
If You Want To specify behavior in the a1.css file used by ff.aspx, you must:
behavior: URL (images/iepngfix. HTC)
of course, this usage is relatively rigid, so that this CSS file can only be used for aspx and HTML files under the root directory, if frm1.aspx in the pub1 directory wants to use this CSS, the above HTC directory is incorrect and should be changed to:
behavior: URL (.. /images/iepngfix. HTC)
Of course, it is better to specify the HTC in each aspx file instead of putting the HTC style into CSS; if you can set the relative path of the website's relative root (/), you can also write it (assuming iepngfix. HTC is fixed in the/images directory under the website root):
behavior: URL (/images/iepngfix. HTC)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.