I have two bootstrap columns, One has a form, another has image. The image division is set to 100% width, Which when resizing the screen, gets responsive. But the form stands to be in same height irrespective of screen size.
Please refer the below code
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="text-page-contents">
<div class="row">
<div class="col-md-6">
<p class="headingdescription" style="padding-left:0px;text-align:left">Request a Office space</p>
<p>Bla bla bla</p>
<div class="col-md-6" style="padding-left:0px">
<input class="formtextarea" placeholder="Full Name " />
<input class="formtextarea" placeholder="Job Title" />
<input class="formtextarea" placeholder="Phone Number" />
</div>
<div class="col-md-6" style="padding-left:0px">
<input class="formtextarea" placeholder="Business Name" />
<input class="formtextarea" placeholder="Email Address" />
<input class="formtextarea" placeholder="Zipcode" />
</div>
<input class="formtextarea" placeholder="Message" style="height: 100px !important" /> <br> <br>
<button class="actionbuttons" href="">SUBMIT REQUEST</button>
</div>
<div class="col-md-6">
<img src="http://dummyimage.com/600/f0d/&text=illo.png" width="100%">
</div>
</div>
</div>
Thanks in advance for helping.
3
Answers
If I understood, you wish to see image be aligned to bottom of the form when becoming smaller. You can align the column itself with the class
mt-auto
(margin-top: auto).Demo:
Note, the class
align-items-end
on parent is also good to align both columns to bottom.If you expect the form to resize somehow to be the same height of the image this will not happen.
The reason for the image to behave responsively is that it has an aspect ratio. That means, it has its own native height and width. What you are doing here is to set just the width, and because the aspect ratio, the image height adjusts accordingly.
Form elements have a fixed size by default. They are not supposed to scale like images.
What you can do instead is to set a width of 100% on the inputs and let the width be determined by the width of the parent container. However this will not affect the height of the form elements in any way.
The css for that looks like this:
Note that I have used
[type="text"]
. This selector will only work if you set the type text on your inputs as well like this:If you want your layout to adjust according to the width or height of your screen, I suggest you have a look at media queries in css.
It can be done with Bootstrap but there are 3 problems to overcome:
col-sm-12
to both columns.Here’s a working fiddle.