2

ユーザーから and form を使用して、幅、単位、方向、および段落を取得するフォームを作成するように依頼されましたCGI.pm。次に、CSS ルールによって段落に幅、単位、および方向を適用する必要があります。

を使用して Perl でインライン CSS を記述できるかどうか疑問に思っていましたCGI.pm

例えば:

<p style=width:"user-width user-unit";text-align:"user-justification">
 paragraph</p> 
4

1 に答える 1

6

はい、-styleパラメータを使用して可能です。

例:print h1({-style=>'Color: red;'},'Welcome to Hell');

別の CSS ファイルを作成することもできます。以下は、個別のスタイルシート (style.css) とインライン CSS を使用する例です。

print start_html( -title=>'CGI with Style',
                      -style=>{-src=>'http://www.example.com/style/style.css',
                               -code=>$newStyle}
                     );
    print h1('CGI with Style'),
          p({-class=>'Tip'},
            "Better read the cascading style sheet spec before playing with this!"),
          span({-style=>'color: magenta'},
               "Look Mom, no hands!",
               p(),
               "Whooo wee!"
               );
    print end_html;

出典: CGI.pm ドキュメント

于 2013-06-18T07:36:37.953 に答える