如何通过css在echo语句下为表单添加样式


how to add style to form under echo statement by css

我想通过echo语句对php中生成的表单进行样式设置。如何做到这一点??请帮我

echo "<form id='form1' name='form1' method='post' action='result.php' class='form_style'>";
    .form_style input[type=submit] 
        {
            border: 0;
            border-radius: 2px;
            padding: 8px 16px;
            cursor: pointer;
            font: 15px;
            font-family:'lucida sans', 'trebuchet MS', 'Tahoma';
            color: #fff;
            text-transform: uppercase;
            background: #3d94f6;     
            text-shadow: 0 -1px 0 rgba(0, 0 ,0, .3);
        }

您应该在<style></style>标签中回显文档的<head>中的CSS

<head>
    <style type="text/css">
        <?php echo ".form_style input[type=submit] 
        {
            border: 0;
            border-radius: 2px;
            padding: 8px 16px;
            cursor: pointer;
            font: 15px;
            font-family:'lucida sans', 'trebuchet MS', 'Tahoma';
            color: #fff;
            text-transform: uppercase;
            background: #3d94f6;     
            text-shadow: 0 -1px 0 rgba(0, 0 ,0, .3);
        }"; ?>
    </style>
</head>

不过,如果这不需要动态,我只需要将样式添加到样式表中。

echo "<form id='form1' name='form1' method='post' action='result.php'   class='form_style'>";
echo "<style>.form_style input[type=submit]". 
    "{".
        "border: 0;".
        "border-radius: 2px;".
        "padding: 8px 16px;".
        "cursor: pointer;".
        "font: 15px;".
        "font-family:'lucida sans', 'trebuchet MS', 'Tahoma';".
        "color: #fff;".
        "text-transform: uppercase;".
        "background: #3d94f6;".     
        "text-shadow: 0 -1px 0 rgba(0, 0 ,0, .3);".
    "}</style>";