I should do it like on this picture. The two fields should be horizontally aligned and flexible. I think that these fields should be two divs in one mother div?
.parentField {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 20px;
border: 1px solid black;
width: 50%;
}
.field1 {
margin: 10px;
border: 1px solid red;
}
.field2 {
margin: 10px;
border: 1px solid red;
}
.browse {
background-color: green;
color: white;
width: 80px;
height: 30px;
margin-bottom: -500%;
margin-left: 80%;
margin-top: -500%;
}
.text {
text-align: center;
margin: 0 auto;
padding-top: 14px;
font-size: small;
padding-right: 80px;
}
.or {
text-align: center;
margin-top: -30px;
}
.text1 {
text-align: center;
margin: 0 auto;
padding-top: 14px;
font-size: small;
padding-right: 80px;
}
.browse1 {
background-color: green;
color: white;
width: 80px;
height: 30px;
margin-bottom: 60px;
}
<div class="parentField">
<div class="field1">
<p class="text">Upload a Power Point presentation .pptx .pptm .ppt</p>
<button class="browse">Browse</button>
</div>
<p class="or">or</p>
<div class="field2">
<p class="text1">Upload a Word document .doc .docm .docx</p>
<button class="browse1">Browse</button>
</div>
</div>
3
Answers
You can use flexbox for this one.
You can play with
justify-content
property to find your desired outcome. Also note thatjustify-content
changes element position on the "main" axis. With the propertyflex-direction
which default value is row, you can determine the main axis. So here the main axis is x, and in order to change the elements’ position vertically, you should set thealign-items
property.The best reference for flexbox I’ve found is here: A Complete Guide to Flexbox
You can use Flexbox in order to achieve your desired output. You can refer to my CSS to achieve the same as shown in Screen Shot you shared.
Also, You cannot directly style
<input type="file"
, so instead you can hide it and use the custom button to achieve the same. But to use the custom button you’ll need to add theJavaScript
function as I have used the below code which points to<input type="file"
on the click custom button.