I am noob here, learning new things. I am trying to make this center form.
This is what I have tried so far :-
<!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 >
<h1 >CARD NUMBER CHECKER</h1>
<br>
<br>
<div >
<div >
<div >
<label >Input Number</label>
</div>
<div >
<input type="text" >
</div>
</div>
</div>
<br>
<div >
<button 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>
Getting something like this right now, with above code
Want exactly like this :-
Atleast Help me center the input box like an image :)
CodePudding user response:
Bootstrap 5 has classes that can do all of that for you as opposed to adding other CSS:
https://getbootstrap.com/docs/5.0/utilities/flex/
https://getbootstrap.com/docs/5.0/utilities/spacing/
d-flex
sets the container div to a flexbox, flex-column
sets the direction of the box to a column, align-items-center
aligns everything to the horizontal center, and gap-4
gives you some spacing between all elements. You could even remove the input container all together unless you specifically need it for something else.
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 >
<h1 >CARD NUMBER CHECKER</h1>
<div >
<div >
<label >Input Number</label>
</div>
<div >
<input type="text" >
</div>
</div>
<div >
<button type="button">Submit</button>
</div>
</div>
</body>
</html>
CodePudding user response:
this will center it
.inpCont {
display: flex;
justify-content: center;
}