Get the App
SLTechnology News&Howtos  ›  Development  › 

How to introduce another CSS file into CSS file

Shulou Source: shulou.com Published: 2022-06-01 06:27:56 09月29日 Update

This article mainly explains the "CSS file how to introduce another CSS file", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "how to introduce another CSS file in the CSS file"!

@ import rule

First, let's take a look at the @ import rule.

The @ import rule is used to import one style sheet into another. This rule also supports media queries so that users can import media-related stylesheets. After any @ charset declaration, the @ import rule must be declared at the top of the document.

Features of @ import:

The ● @ import rule is used to import stylesheets into HTML pages or other stylesheets.

The ● @ import rule is also used to add media queries, so import is media dependent.

The ● @ import rule is always declared at the top of the document.

Basic sentence patterns:

@ importurl | stringlist-of-mediaqueries

Url | string: indicates the location of the resource to be imported, which can be relative or absolute.

List-of-mediaqueries: determines the application of the CSS rules defined in the URL link.

Code example

Let's take a look at how to introduce another CSS file into a CSS file through an example.

HTML section: create a file named index.html

PHP Chinese website

Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text! Test the text!

CSS section:

Style1.css file:

/ * Import another CSS file * /

@ import "style2.css"; / * or @ importurl (style2.css); * /

.box {

Width:400px

Margin:100pxauto

}

H2 {

Color:red

Text-align:center

}

P {

Color:black

Padding:10px

Background-image:linear-gradient (toright,#fbd6d3,#ff1200)

Position:static

}

Thank you for your reading, the above is the content of "how to introduce another CSS file into the CSS file". After the study of this article, I believe you have a deeper understanding of how to introduce another CSS file into the CSS file. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Text tests files rules styles media learning content documents examples parts top query Chinese web code location sentence patterns that is ideas situations Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL vpn Apple OPPO Reno Microsoft