html - 输入值与标签值不一致

标签 html css forms

这是 HTML 和关联的 CSS。谁能指出我做错了什么?输入文本框出现在其相应标签下方。

form label.blockLabel {
    display: block;
    position: relative;
    width: 450px;
    margin: 12px 0px 12px 0px;
}

form fieldset#contactFields input {
    position: absolute;
    margin-left: 140px;
}
<form name="contactForm" id="contactForm" method="POST" action="mailto:eric.franklin@ucdenver.edu">
<p>* indicates a required field</p>

<fieldset id="contactFields">
    <legend>Contact Information</legend>                        
        <label class="blockLabel" for="fName">First Name<span>*</span></label>
            <input type="text" id="fName" name="fName" required="required" />                           
        <label class="blockLabel" for="lName">Last Name<span>*</span></label> 
            <input type="text" id="lName" name="lName" required="required" />
        <label class="blockLabel" for="email">Email Address<span>*</span></label>   
            <input type="email" id="email" name="email" required="required" />
        <label class="blockLabel" for="street">Street Address</label>   
            <input type="text" id="street" name="street" />
        <label class="blockLabel" for="city">City</label>   
            <input type="text" id="city" name="city" value="Denver" />
        <label class="blockLabel" for="state">State</label>     
            <input type="text" id="state" name="state" value="CO" maxlength="2" />
        <label class="blockLabel" for="zip">Zip</label> 
            <input type="text" id="zip" name="zip" maxlength="10" />
        <label class="blockLabel" for="phone">Phone</label> 
            <input type="tel" id="phone" name="phone" />                             
</fieldset>

最佳答案

这是一个 fiddle 。我想你只需要删除

form fieldset

选择器。

http://jsfiddle.net/plushyObject/cL6jm2r4/

关于html - 输入值与标签值不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28891155/

相关文章:

javascript - 我怎样才能给菜单项激活类

javascript - 如何添加不同的占位符颜色

javascript - 单击链接时将类添加到 <li>

javascript - 使用 jQuery 更改文本输入值

jquery - php ajax表单提交而不刷新父页面

html - 当容器比屏幕宽时填充正确?

javascript - 有什么方法可以在Javascript中同时显示隐藏多个密码吗?

css - 使用 if 语句 HTML 分配类

css - 设置输入框背景

javascript - 默认情况下隐藏覆盖时,jquery 画廊不可见