CSS表单 - 输入宽度不起作用

jkc*_*kcl 7 css

以下css:

#contactform {
    width: 400px;
    height: 215px;
}

.webform {
}

.webform input .name {
    width: 50px;
}

.webform input .email {
    width: 70px;
}

.webform input .comments {
    width: 200px;
}
Run Code Online (Sandbox Code Playgroud)

当在html中使用时

    <div id="contactform">
        <div class="webform">
            <input class="name" name="Name" type="text" id="senderName" placeholder="Enter your name here">
            <input class="email" name="Email" type="text" id="senderEmail" placeholder="Enter a valid email adress here">
            <br>
            <input class="comments" name="Comments" type="text" id="senderComments" placeholder="Comments...">
        </div>
    </div>
Run Code Online (Sandbox Code Playgroud)

产生相同宽度的所有三个输入字段(50px =即宽度webform input).我不确定我做错了什么.救命?

alb*_*ert 7

你的课程是你input的,而不是s的儿童元素input.所以改变input .name,等等,input.name或只是.name,重复这三个.:)


Zol*_*oth 5

删除输入和类名之间的空格

.webform input.name {
    width: 50px;
}

.webform input.email {
    width: 70px;
}

.webform input.comments {
    width: 200px;
}
Run Code Online (Sandbox Code Playgroud)

试试这个小提琴