我想让我的输入文本框和按钮行内,但是如果我从 div 中洗掉 d-flex 类,我就无法通过将内容置于中心来证明其合理性。有什么想法可以使它们行内或证明内容合理?
这是我的代码,
<!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" />
<title>Movies</title>
<!-- Bootstrap -->
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0"
crossorigin="anonymous"
></script>
<!-- css -->
<link rel="stylesheet" href="/css/styles.css" />
</head>
<body class="bg-image shadow-2-strong">
<div class="mask">
<div
class="
container
d-flex
flex-column
align-items-center
justify-content-center
text-center
h-100
"
>
<div>
<h1 class="mb-3">THE MOVIE SCOPE!</h1>
<h5 class="mb-4">search with movie titles</h5>
<input type="text" class="form-control" required />
<form action="/" method="post">
<button type="submit" class="btn btn-outline-light btn-lg">
click
</button>
</form>
</div>
</div>
</div>
<footer>
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2)">
? 2021 Copyright Danuja Jayasuriya
</div>
</footer>
</body>
</html>
这是现在的样子, https://ibb.co/8jkG75K
uj5u.com热心网友回复:
添加一个 div 以覆写<input> and <form>
class d-flex
,添加填充或边距以自定义文本框和按钮之间的空间。比如我ms-4
给按钮加了div。
<!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" />
<title>Movies</title>
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous" />
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
<!-- css -->
<link rel="stylesheet" href="/css/styles.css" />
</head>
<body class="bg-image shadow-2-strong">
<div class="mask">
<div class="container d-flex flex-column align-items-center justify-content-center text-center h-100">
<h1 class="mb-3">THE MOVIE SCOPE!</h1>
<h5 class="mb-4">search with movie titles</h5>
<div>
<div class="d-flex">
<input type="text" class="form-control" required />
<form action="/" method="post">
<button type="submit" class="btn btn-outline-light btn-lg ms-4">click</button>
</form>
</div>
</div>
</div>
</div>
<footer>
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2)">? 2021 Copyright Danuja Jayasuriya</div>
</footer>
</body>
</html>
0 评论