套一个div ,然后右对齐。
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/d043ad4bd11373f0fcf23c99ae0f4bfbfaed04e2?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>居中对齐</title>
<style>
.a{
width: 300px;
height: 30px;
}
#b{
width: 500px;
border: 1px solid red;
text-align: right; /*右对齐*/·
}
</style>
</head>
<body>
<div id="b">
<form action="">
姓名:<input type="text" class="a" value=""><br><br>
年龄:<input type="text" class="a" value=""><br><br>
兴趣爱好:<input type="text" class="a" value="">
</form>
</div>
</body>
</html>