I know this is a very trivial and beginner-like question, and I know this is a common question answered many times in a lot of different ways. What I'm asking for is guidance, a lot of the solutions are given without the context and many are not beginner-friendly. I'm trying to understand everything I can about the methods and how to use them in other situations.
This situation: What I wanted to accomplish was a centered block, relative to the page, I've done it. Now I would like to set an input box centered within the block as well, but it happens to not being centered, even inside a flex
. (I've heard somewhere that if an element inside a display: flex
, it also becomes flex
), why isn't it the case here?
If I'm not asking too much, please give an explanation on why do "x" and "y" to achieve the result.
Here's what I've got so far
html,body{
height: 100%
}
#content {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
#box{
width: 350px;
height: 300px;
border: 1px solid black;
}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="content">
<div id="box">
<input id = "inputFile" type="file" name="inFile" multiple>
</div>
</div>
</body>
</html>