是否可以使用perl CGI.pm编写带内联css的HTML文件?

fem*_*chi 2 perl cgi perl-module

我被要求制作一个表格,通过使用CGI.pm和来自用户的表格获得宽度,单位,方向和段落.然后我需要通过CSS规则将宽度,单位和方向应用于段落.

我想知道是否可以使用Perl编写内联CSS CGI.pm.

例如:

<p style=width:"user-width user-unit";text-align:"user-justification">
 paragraph</p> 
Run Code Online (Sandbox Code Playgroud)

Cha*_*hak 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;
Run Code Online (Sandbox Code Playgroud)

资料来源:CGI.pm docs