Reputation: 3774
I am using some style to increase the area of input file element. In order to ease dropping file to this element i would like to increase its area. Using the css property width and height increases the area but is there a way to align the choose file to the middle or center.
<div id="container">
<input type=file style="border: 1px solid black; width: 400px; height: 400px;">
</div>
Is it possible to achieve something like this using just css and html? I appreciate any help!
Upvotes: 1
Views: 1825
Reputation: 2922
You can use CSS to make the Drag&Drop section the size of the whole container:
.file {
height: 300px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
width: 100%;
}
.file-input {
width: 100%;
height: 100%
}
<div class="file">
<input class="file-input" type="file">
</div>
But in order to center the "Preview" and have all the area to Drag&Drop you must use Js, here is a CodePen that you could you as a base: https://codepen.io/prasanjit/pen/NxjZMO.
Upvotes: 2
Reputation: 598
Just add some padding:
input {
border: 1px solid black;
padding: 100px;
}
<div id="container">
<input type=file>
</div>
Upvotes: 0