这是一个关于html元素样式的问题


this is an issue concerning styling html elements

下面是我的代码,假设创建一个搜索框,然后对其进行样式设置。由于某些原因,我试图赋予该框的css属性不适用。我尝试将css放在一个单独的文件中,也放在如下所示的脚本中。问题是什么(我使用的是netbeans,文件是.php)

这是代码:

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title>cats</title>
    </head>
    <body>
        <form>
            <input type="text" placeholder="Search me..." required>
            <input type="button" value="Search">
        </form>
        <style type="text/css" media="screen">
form {
                width:500px;
                margin:50px auto;
}
.Search {
                padding:8px 15px;
                background:rgba(50, 50, 50, 0.2);
                border:0px solid #dbdbdb;
}
.button {
                position:relative;
                padding:6px 15px;
                left:-8px;
                border:2px solid #207cca;
                background-color:#207cca;
                color:#fafafa;
}
.button:hover  {
                background-color:#fafafa;
                color:#207cca;

        </style>
        <?php
        // put your code here
        ?>
    </body>
</html> 

您使用的是CSS类选择器。给你想要样式化的元素适当的类属性(正如patricksweeney所暗示的):

form {
    width:500px;
    margin:50px auto;
}
.search {
    padding:8px 15px;
    background:rgba(50, 50, 50, 0.2);
    border:0px solid #dbdbdb;
}
.button {
    position:relative;
    padding:6px 15px;
    left:-8px;
    border:2px solid #207cca;
    background-color:#207cca;
    color:#fafafa;
}
.button:hover {
    background-color:#fafafa;
    color:#207cca;
}
<form>
    <input type="text" class="search" placeholder="Search me..." required>
    <input type="button" class="button" value="Search">
</form>