【发布时间】:2019-10-08 20:06:03
【问题描述】:
我必须对齐字段(右),如下图所示。这是我在 Angularjs 中构建的代码,使用表单中的所有图例的标签标记,我使用 CSS 设置样式。如何更正对齐,以便我可以将其提交给上级?
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<head>
<title> SAP WORKBENCH </title>
<style>
body{
background-color: lightgray;
margin-left: 500px
}
.option{
width: 300px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
.button{
width: 300px;
}
</style>
</head>
<h2>Password Reset</h2>
<body>
<div ng-app="">
<b></b>
<form>
<label>System:</label>
<select class="option" ng-model="myVar">
<option></option>
<option value = "DR9">DR9</option>
<option value = "QR9">QR9</option>
<option value = "PR3">PR3</option>
</select>
<br><br>
<div ng-switch="myVar">
<label>Client:</label>
<select class="option" ng-switch-when="DR9">
<option>100</option>
<option>400</option>
<option>500</option>
</select>
<select class="option" ng-switch-when="QR9">
<option>500</option>
</select>
<select class="option" ng-switch-when="PR3">
<option>500</option>
</select>
<select class="option" ng-switch-default>
<option></option>
</select>
</div>
<br>
<label>User:</label>
<input class="option" type="text" placeholder="Enter User Id.."></input>
<br><br>
<label>New Password:</label>
<input class="option" type="password"></input>
<br><br>
<label>Re-Enter New Password:</label>
<input class="option" type="password"></input>
<br><br>
<input class="button" type="button" value="Reset">
</form>
</div>
</body>
</html>
【问题讨论】:
-
??正文 500px 边距,为什么? . label 也可以通过 width 和 display 和 text-align 重置来调整大小,button 的左边距可以等于 labels 的大小。
body { background-color: lightgray; /*margin-left: 500px*/ } .option { width: 300px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } label { display:inline-block; width:200px; text-align:right; } .button { width: 300px; margin-left:205px; }无需更新结构,也无需在此处使用网格或 flex。除非您需要更多灵活性,否则旧方法很好 -
您好,谢谢您的输入。另外,您看到我附上的图片了吗?请仔细阅读并提供相应的帮助
-
您的 HTML 无效。