我在這里是菜鳥,學習新事物。我正在嘗試制作這種中心形式。
這是我到目前為止所嘗試的:-
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X R7YkIZDRvuzKMRqM OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<style>
.container {
height: 100%;
width: 50%
}
.center-block {
margin: auto;
display: block;
}
</style>
</head>
<body>
<div class="container">
<h1 class="text-center fst-italic mt-5">CARD NUMBER CHECKER</h1>
<br>
<br>
<div class="inpCont ">
<div class="row g-3 align-items-center">
<div class="col-auto">
<label class="col-form-label text-center">Input Number</label>
</div>
<div class="col-auto">
<input type="text" class="form-control text-center">
</div>
</div>
</div>
<br>
<div class="d-grid gap-2 col-3 mx-auto">
<button class="btn btn-warning" type="button">Submit</button>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
</body>
</html>
現在得到這樣的東西,上面的代碼
想要完全一樣:-
至少幫我把輸入框像影像一樣居中:)
uj5u.com熱心網友回復:
Bootstrap 5 的類可以為您完成所有這些作業,而不是添加其他 CSS:
https://getbootstrap.com/docs/5.0/utilities/flex/
https://getbootstrap.com/docs/5.0/utilities/spacing/
d-flex
將容器 div 設定為 flexbox, flex-column
將盒子的方向設定為列,align-items-center
將所有內容與水平中心對齊,并gap-4
在所有元素之間提供一些間距。您甚至可以一起洗掉輸入容器,除非您特別需要它來做其他事情。
h1 {
font-family: Georgia, "Times New Roman", Times, serif;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X R7YkIZDRvuzKMRqM OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
</head>
<body>
<div class="d-flex flex-column align-items-center gap-4">
<h1 class="text-center mt-5">CARD NUMBER CHECKER</h1>
<div class="row g-3 align-items-center">
<div class="col-auto">
<label class="col-form-label text-center">Input Number</label>
</div>
<div class="col-auto">
<input type="text" class="form-control text-center">
</div>
</div>
<div class="d-grid gap-2 col-3 mx-auto">
<button class="btn btn-warning" type="button">Submit</button>
</div>
</div>
</body>
</html>
uj5u.com熱心網友回復:
這將使其居中
.inpCont {
display: flex;
justify-content: center;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/494654.html