2

@importステートメントを <link>タグに変換するスクリプトを作成しようとしていますが、2 つの質問があります。

  1. ステートメントと他のスタイル ステートメントをタグ@import内に共存させることはできますか? <style>例えば:

    <style type="text/css">
        @import url(http://www.example.com/style.css);
        body {
            background: #FFF;
        }
        ..NUI_ContentFrameHeader_l {
            clear: both;
            height: 50px;
            margin: 0;
            color: black;
            background: url(/vpn/images/NUI_box_l.png) no-repeat left top;
            border: solid 0px #BBC6D6;
            overflow: hidden;
            letter-spacing: 0;
            padding: 0 0 0 15px;
        }
    </style>
    
  2. @importタグの先頭に複数のステートメントが<style>あり、これがスコープ スタイル タグではない場合、@importステートメントを<link>ステートメントに変換してタグのすぐ上に移動でき<style>ますか? お気に入り:

    <style type="text/css">
        @import url(http://www.example.com/style1.css);
        @import url(http://www.example.com/style2.css)
        body {
            background: #FFF;
        }
        ..NUI_ContentFrameHeader_l {
            clear: both;
            height: 50px;
            margin: 0;
            color: black;
            background: url(/images/NUI_box_l.png) no-repeat left top;
            border: solid 0px #BBC6D6;
            overflow: hidden;
            letter-spacing: 0;
            padding: 0 0 0 15px;
        }
    </style>
    

    となります:

    <link type="text/css" media="screen" rel="stylesheet"
                            href="http://www.example.com/style1.css" />
    <link type="text/css" media="screen" rel="stylesheet"
                            href="http://www.example.com/style2.css" />
    <style type="text/css" media="screen">
        body {
            background: #FFF;
        }
        ..NUI_ContentFrameHeader_l {
            clear: both;
            height: 50px;
            margin: 0;
            color: black;
            background: url(/images/NUI_box_l.png) no-repeat left top;
            border: solid 0px #BBC6D6;
            overflow: hidden;
            letter-spacing: 0;
            padding: 0 0 0 15px;
        }
    </style>
    
4

1 に答える 1

0

タグ内で @import ステートメントと他のスタイル ステートメントを共存させることはできますか?

はい。

タグの先頭に複数の @import ステートメントがあり、これがスコープ スタイル タグではない場合、@import ステートメントをステートメントに変換して、タグのすぐ上に移動できますか?

はい。

ファイルの読み込みをブロックするため、ステートメントを独自のスタイルシートに変換することがベスト プラクティスと見なされます。ステートメントが独自のタグで個別のシートとして読み込まれる場合は、ブラウザーによって並行して読み込まれます。@import@import<style>

于 2013-02-08T04:33:33.570 に答える