https://plnkr.co/edit/vWR7kK9MQw4nyciRt1Bj?p=preview
I have uploaded my code in plunker. Till media screen size 768px,1260px form is responsive.I need to have atleast three input fields per row at media screen level 480px-760px , but All I get is only one field per row. After that at media screen at minimum size 480px per row only one field is coming. Need assistance.
I tried adjusting width of fields. For your reference Css and Html code as follows:
HTML :
<form name="tForm" role="form" data-ng-init="resp()">
<div class="row newRow">
<div class="form-group fields col-sm-2" ng-class="{'has-error': (tForm.fname.$dirty || tForm.$submitted) && tForm.fname.$invalid }">
<label for="fname">FIRST NAME *</label>
<br>
<input type="text" name="fname" class="form-control1 col-sm-2" autocomplete="off" ng-required="true" ng-model="firstName" ng-pattern="/^[a-zA-Z ]*$/" ng-minlength=1/>
</div>
<div class="form-group fields col-sm-2">
<label>LAST NAME *</label>
<input type="text" name="lname" class="form-control1" autocomplete="off" ng-required="true" ng-model="lastName" />
</div>
<div class="form-group fields col-sm-2">
<label>GENDER *</label>
<br>
<select name="gender" class="form-control1 drop" required ng-model="gender" placeholder="select">
<option value='' disabled selected>Select</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="transpant">Transgender</option>
</select>
</div>
<div class="form-group fields col-sm-2">
<label>DOB</label>
<div class="form-group">
</div>
</div>
</div>
</form>
CSS:
@media screen and (min-width: 480px) {
.newrow {
width: 100;
}
.firstfields {
margin-top: 10px;
margin-left: 5px;
}
.drop2 {
padding: 6px;
padding-right: 3em;
border: none;
color: black;
width: 85%;
}
.fields {
border: 1px #A9A9A9 solid;
width: 200px;
margin: 1em;
height: 75px;
color: #A9A9A9;
font-size: 11px;
}
input[type=text] {
width: 65%;
margin: 8px 0;
box-sizing: border-box;
border: 3px solid #fff;
-webkit-transition: 0.5s;
transition: 0.5s;
outline: none;
}
input[type=email] {
width: 65%;
margin: 8px 0;
box-sizing: border-box;
border: 3px solid #fff;
-webkit-transition: 0.5s;
transition: 0.5s;
outline: none;
}
input[type=email]:focus {
border: 3px solid #fff;
}
.drop {
width: 160px;
}
.drop select:focus {
box-shadow: 0 0 3pt 2pt #fff!important;
}
.drop1 {
width: 85%;
padding: 6px;
padding-right: 6em;
border: none;
color: black;
}
input[type=text]:focus {
border: 3px solid #fff;
}
.newpagebody {
background-size: auto;
}
}
For targeting specific screen size below 768px width, you can use col-xs-* class.
So, to have 3 input fields per row, you should add col-xs-4 class to the form-group.
like -
class="form-group fields col-xs-4 col-sm-2"
Additionally, for below 768px resolution you need to remove given additional width to the .fields as well as .newrow class.
as below -
@media screen and (min-width: 480px)
.newrow {
/* width: 100; */ /* removed */
}
@media screen and (min-width: 480px)
.fields {
border: 1px #A9A9A9 solid;
/* width: 200px; */ /* removed */
margin: 0em; /* editied - to avoid impact on responsiveness */
height: 75px;
color: #A9A9A9;
font-size: 11px;
}
@media screen and (min-width: 480px)
input[type=text] {
width: 100%; /* edited */
/* padding: 12px 20px; */ /* removed */
margin: 8px 0;
box-sizing: border-box;
border: 3px solid #fff;
-webkit-transition: 0.5s;
transition: 0.5s;
outline: none;
}
@media screen and (min-width: 480px)
.drop {
width: 100%; /* edited */
}
For more information about responsive grid system read - http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With