[英]HTML form Radio button positioning
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form >
<label>Name</label>
<input type="text">
<br>
<label>Email</label>
<input type="email" name="">
<br>
<label>Date</label>
<input type="date" name="">
<br>
<label>Password</label>
<input type="password" name="">
<br>
<label>Color</label>
<input type="color" name="">
<br>
<label>Select Any One</label>
<input type="checkbox" name="">Travel
<input type="checkbox" name="">Food
<input type="checkbox" name="">Hotel
<br>
<label>Select Gender</label>
<input type="radio" name="gender">Male
<input type="radio" name="gender">FeMale
<br>
<select>
<option>Select Box</option>
</select>
<br>
<textarea rows="4" cols="50"></textarea>
</form>
</body>
</html>
单选按钮不仅仅位于“ Male
和“ Female
标签的前面,因为您已将CSS
中每个元素的宽度设置为100%
*{
margin:0px auto;
width:100%; <------ This is what's causing the problem
}
只需去除width: 100%
解决您的问题
*{
margin:0px auto;
}
或者,您可以只使用position
属性定位它们。
在style
标签中添加以下课程
<!-- CSS -->
#form form input[type="radio"]{
position:relative;
top: -19px;
}
从以下代码中删除width:100%
解决了jsfiddle中的问题
*{
margin:0px auto;
}
这是因为该样式适用于所有放置了文本和单选按钮的元素
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.