I have a simple DIV that has several input forms, and textarea inputs and a submit button. Now I would like this div to be centered in the center of the page instead of to the left how is it by default. I have tried all of the DIV centering methods I found searching but they always mess up the alignment of the text forms in the DIV when it is centered.
How could I center something like this in the middle of the page?
<style>
div.container {
width: 70%;
}
input[type="text"] {
margin: 0 auto;
width: 50%;
display: block;
float: left;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid black;
border-radius: 4px;
}
input[type="submit"] {
margin: 0 auto;
width: 100%;
display: block;
float: left;
background-color: #4CAF50;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
border-radius: 4px;
cursor: pointer;
}
textarea {
width: 50%;
float: left;
resize: vertical;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid black;
border-radius: 4px;
}
</style>
<div class="center-div">
<div class="container">
<input type="text">
<input type="text">
<textarea id="text1" name="textbox" rows="10" cols="100" ></textarea>
</textarea>
<textarea id="text2" name="textbox" rows="10" cols="100"></textarea>
</textarea>
<br>
<input type="submit">
</div>
</div>