gpt4 book ai didi

html - 表单中文本域的对齐方式

转载 作者:太空宇宙 更新时间:2023-11-04 12:31:06 25 4
gpt4 key购买 nike

我想在我的表单中对齐我的文本字段,但我找不到实现它的方法。我将让您看到一个想要文本字段开始的打印屏幕。这是我的代码...

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<form method="post" action="signup.php">
<fieldset>
<legend>Registration Form</legend>
<label>First Name :
<input type="text" name="fname" required="required" />
</label>
<br/>
<br/>
<label>Last Name :
<input type="text" name="lname" required="required" />
</label>
<br />
<br />
<label>Username :
<input type="text" name="username" required="required" />
</label>
<br />
<br />
<label>Email :
<input type="text" name="email" required="required" />
</label>
<br />
<br />
<label>Password :
<input type="text" name="password" required="required" />
</label>
<br/><br/>
User Type:
<br/>Doctor
<input type="radio" name="answer" value="Doctor" />
Patient
<input type="radio" name="answer" value="Patient" />

<!--DOCTOR OPTIONS -->
<div id="expandDoctor" style="display:none;">
<label id="Male">Male</label>
<input type="radio" name="DoctorG" value="male" id="DoctorG">
<label id="Female">Female</label>
<input type="radio" name="DoctorG" value="female" id="DoctorG">
<br/>
<br/>
<label id="Age">Age:</label>
<input type="text" name="DoctorAge" id="DoctorAge" />
<br/>
<br/>
<label id="Specialty">Specialty:</label>
<select id="SelectSpecialty" name="specialty">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>
<br/>
<br/>
<label id="ID">Doctor ID:</label>
<input type="text" name="Doctor_ID" id="Doctor_ID" />
</div>

<!--PATIENT OPTIONS -->
<div id="expandPatient" style="display:none;">
<label id="Male">Male</label>
<input type="radio" name="PatientG" value="male" id="PatientGM">
<label id="Female">Female</label>
<input type="radio" name="PatientG" value="female" id="PatientGF">
<br/>
<br/>
<label id="Age">Age:</label>
<input type="text" name="PatientAge" id="PatientAge" />
<br/>
<br/>
<label id="Disease">Disease:</label>
<select id="SelectDisease" name="disease">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>
<br/>
<br/>
<label id="SPID">SPID:</label>
<input type="text" name="PatientSPID" id="PatientSPID" />
</div>
</fieldset>

<input type="submit" value="Register" name="register"/>
</form>
</body>
<script>
$("input[type='radio'][name='answer']").change(function() {
$("[id^=expand]").hide();
$("#expand" + $(this).val()).show();
});</script>

</body>
</html>

我希望文本字段在我放置红线的位置对齐你能帮我吗? I want the textfield to start in the place where i put the red line

最佳答案

将所有input包裹在label中并添加width并将input设置为float:right

label {
width: 280px;
display: inline-block;
}
label input {
float: right;
}
<html>

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>

<body>
<form method="post" action="signup.php">
<fieldset>
<legend>Registration Form</legend>
<label>First Name :
<input type="text" name="fname" required="required" />
</label>
<br/>
<br/>
<label>Last Name :
<input type="text" name="lname" required="required" />
</label>
<br />
<br />
<label>Username :
<input type="text" name="username" required="required" />
</label>
<br />
<br />
<label>Email :
<input type="text" name="email" required="required" />
</label>
<br />
<br />
<label>Password :
<input type="text" name="password" required="required" />
</label>
<br/>
<br/>User Type:
<br/>Doctor
<input type="radio" name="answer" value="Doctor" />Patient
<input type="radio" name="answer" value="Patient" />
<!--DOCTOR OPTIONS -->
<div id="expandDoctor" style="display:none;">
<label id="Male">Male</label>
<input type="radio" name="DoctorG" value="male" id="DoctorG">
<label id="Female">Female</label>
<input type="radio" name="DoctorG" value="female" id="DoctorG">
<br/>
<br/>
<label id="Age">Age:</label>
<input type="text" name="DoctorAge" id="DoctorAge" />
<br/>
<br/>
<label id="Specialty">Specialty:</label>
<select id="SelectSpecialty" name="specialty">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>
<br/>
<br/>
<label id="ID">Doctor ID:</label>
<input type="text" name="Doctor_ID" id="Doctor_ID" />
</div>
<!--PATIENT OPTIONS -->
<div id="expandPatient" style="display:none;">
<label id="Male">Male</label>
<input type="radio" name="PatientG" value="male" id="PatientGM">
<label id="Female">Female</label>
<input type="radio" name="PatientG" value="female" id="PatientGF">
<br/>
<br/>
<label id="Age">Age:</label>
<input type="text" name="PatientAge" id="PatientAge" />
<br/>
<br/>
<label id="Disease">Disease:</label>
<select id="SelectDisease" name="disease">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>
<br/>
<br/>
<label id="SPID">SPID:</label>
<input type="text" name="PatientSPID" id="PatientSPID" />
</div>
</fieldset>
<input type="submit" value="Register" name="register" />
</form>
</body>
<script>
$("input[type='radio'][name='answer']").change(function() {
$("[id^=expand]").hide();
$("#expand" + $(this).val()).show();
});
</script>
</body>

</html>

关于html - 表单中文本域的对齐方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27648190/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com