I'm diving into the world of HTML/CSS and grappling with various concepts. My goal is to vertically align 2 divs within a larger div, as well as center the contents within those divs.
HTML:
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div id="MainDiv">
<div id="SubDiv">
<form method="POST">
<input type="text" name="example1" class="Text">
<input type="text" name="example2" class="Text">
<input type="submit" value="Go"> <br>
</form> <br/>
</div>
<div id="SubDiv">
<input type="button" value="Button 1"/>
<input type="button" value="Button 2"/>
</div>
</div>
</body>
CSS:
#MainDiv
{
width: 60%;
height: 30%;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
text-align: center;
border: 1px solid black;
}
#SubDiv
{
width: 90%;
height: 45;
margin: auto;
border: 1px solid black;
}
.Text
{
width: 40%;
}
Check out the result here: the main div centered perfectly, but I'm struggling with vertical alignment of other elements.
Despite my efforts to find solutions, nothing seems to work or only complicates things further. Any guidance would be greatly appreciated.