I'm having trouble aligning a submit button to the right within a Bootstrap form. I've experimented with float-right
, text-right
, and align="right"
, but none of them seem to be working. Below is the code snippet:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.0-beta1/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.0-beta1/js/bootstrap.min.js"></script>
<title>Document</title>
</head>
<body>
<form role="form" id="sendAddress" action="/sendAddress" method="post">
<select class="form-select" aria-label="Default select example" name="role">
<option value="r">随机</option>
<option value="w">战士</option>
<option value="t">坦克</option>
<option value="a">刺客</option>
</select>
<div class="float-right text-right">
<input type="submit" value="Submit" name="selectedvalue" class="btn btn-primary" style="float: right;">
</div>
</form>
</body>
</html>