如何在css的echo语句下添加样式

时间:2014-09-02 18:27:23

标签: php html 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);
        }

2 个答案:

答案 0 :(得分:0)

您应该在<head>标记内的文档<style></style>中回显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>

虽然,如果不需要动态,我只想将样式添加到样式表中。

答案 1 :(得分:0)

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>";