2017-09-16 14 views
0

を使用してCSSファイルをHTMLでインラインスタイルに変換します。外部スタイルシートのスタイルをインラインで頭の上部に1つのインライン<style>タグとしてインライン化するような、外部CSSファイル付きのHTMLファイルがあります。任意の助けを事前に感謝npmパッケージ

p { 
 
    color: red; }
<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
\t <meta charset="utf-8"> 
 
\t <title>HTML Template</title> 
 
\t <link rel="stylesheet" type="text/css" href="css/mystyle.css"> 
 
\t <script type="text/javascript" src="js/myscript.js"></script> 
 
</head> 
 
<body> 
 
\t <p>Welcome to Template!!</p> 
 
</body> 
 
</html>
を変換する前に、トップ

1個のスタイルタグを持つようにしたい、スタイル属性が各要素に適用される使用したくありません

変換後

<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
\t <meta charset="utf-8"> 
 
\t <title>HTML Template</title> 
 
    <!-- START: Replaced inline tag from external css file mystyle.css as above--> 
 
\t <style> 
 
    .p{color:red} 
 
    </style> 
 
    <!-- END: Replaced inline tag from external css file mystyle.css as above--> 
 
\t <script type="text/javascript" src="js/myscript.js"></script> 
 
</head> 
 
<body> 
 
\t <p>Welcome to Template!!</p> 
 
</body> 
 
</html>

答えて

0

あなたが開いローカルホストでアクセスできることを確認してください、あなたがPHPを使用している場合、あなたはコマンドphp -S 127.0.0.1:4000次の実行により、それがアクセスできるようにすることができ、Webブラウザ からHTMLファイルにアクセスできるようにすることによって開始することができます:4000にWebブラウザは、どのようにアクセス可能な他の言語から別の方法があるが、それはこの質問の範囲外だ

第二段階は、inliner NPMパッケージにnpm install -g inliner

とexecuをインストールしていますあなたは

base64エンコードするイメージを変換したくない場合は

オープンoutput.html TE inliner http://localhost:4000 > output.html

inliner -i http://localhost:4000 > output.htmlを実行し、結果を表示するには

関連する問題