How Do I Center The Input Fields On This Form? - forms

https://ibb.co/3M8TjjY
Codepen
https://codepen.io/shon-lucky/pen/WNozGRe?editors=1100
Trying to center this form and its beating me up. So far i have used margin: auto. But everytime i do the form centers but the input elements are not centered in the form. I have used positioning where i made the parent container relative and made the form absolute but the everything dissapears before i even try to move it. Can someone help me with this plz
<form action="">
<div class="firstrow">
<label for="How Many People">How Many People</label>
<input type="text">
</div>
<div class="firstrow">
<label for="date">Date</label>
<input type="text">
</div>
<div class="firstrow">
<label for="time">Time</label>
<input type="text">
</div>
<br style="clear:both">
<div class="secondrow">
<label for="name">Name</label>
<input type="text" placeholder="Your full name">
</div>
<div class="secondrow">
<label for="email">Email</label>
<input type="text">
</div>
<div class="secondrow">
<label for="Phone">Phone</label>
<input type="text" placeholder="You phone">
</div>
</div>
</form>
</section>
.section4{
width:100%;
height: 380px;
background-color: #374a5c;
}
.section4 .wrapper{
width:80%;
height:380px;
margin:auto;
border: 1px solid red;
}
form{
}
label,input{
display:block;
}
.firstrow{
float: left;
}
.secondrow{
float:left;
}

Thank you for the Codepen! Here is a fix to center the form elements:
Link to the edited pen : https://codepen.io/pathiout/pen/YzpaLdR?editors=1100
Here is the css I used :
.firstrow {
display: inline-block;
margin: 10px auto;
}
.secondrow {
display: inline-block;
}
Basically I removed the "float left" attributes that prevents any centering from parent. Is this an acceptable solution for you ?

Have you tried text-align? Sometimes in HTML, the text align can center html element other than text, I've used it many times already.
<div style="text-align: center"><input type="text"> ....

Related

Centering a search form using the bootstrap 3 on different screen sizes

Can any one help me centering a search bar in the center of the screen for different screen size, just like the googles search bar?
I have tried many ways but nothing worked.
<form class="form input-group" role="search">
<div class="form-group center-block input-group-btn col-xs-12 col-sm-12 col-md-12col-lg-12">
<div class="center-block" style="width: auto;">
<div class="center-block ">
<input type="text" class="form-control text-center" style="width: auto;" id="exampleInputAmount" placeholder="Search">
<button type="submit" class="btn btn-default"> <i class="fa fa-search" aria-hidden="true"></i> </button>
</div>
</div>
</div>
</form>
This CSS will centre your content both vertically and horizontally, which I think is what you are wanting to achieve.
position: absolute;
left: 50%;
top: 50%;

collapse inline form bootstrap

i've added a inline-form to my page, in the main area,
the form is a bit to wide, i would like that it collapse at 991px,
but the rest of the page can collapse at 767px
i understand it can be done with mediaquery but not sure on what to code.
i'm stuck here!
what can i do?
i copied the inline form originally from a navbar of a file, the button is working fine.
it look like this:
<div class="container">
<div class="text-center">
<button
class="btn btn-default form-toggle"
type="button"
data-toggle="collapse"
data-target="#collapseExample"
aria-expanded="false"
aria-controls="collapseExample"> <span class="sr-only"> Toggle navigation</span> Reservations
</button>
</div>
<div id="collapseExample" class="navbar-collapse collapse">
<div class="text-center ">
<form class="form-inline navbar-form" name="bookerform" action="---" method="GET" target="_self">
<div class="form-group">hidden elements</div>
<div class="form-group">arrivo</div>
<div class="form-group">partenza</div>
<div class="form-group text-left"> Numero N</div>
<div class="form-group text-left"> Numero A</div>
<div class="form-group text-left"> Numero B</div>
<div class="form-group"> button check</div>
</form>
</div>
</div>
</div>
thank you for your help,
ok actually i'm almost there.
i like the solution using the bootstrap grid, i've added the media queries but it's not showing as i want, from 992 above it should show only the form, not the button
<div class="container">
<div class="text-center">
<button class="btn btn-default" type="button" data-toggle="collapse" data-target="#myForm"> Reservations
</button>
</div>
<br>
<form class="collapse collapse-class" role="form" id="myForm">
<div class="col-lg-2">
<p>
<input type="email" class="form-control">
</p>
</div>
<div class="col-lg-2">
<p>
<input type="password" class="form-control">
</p>
</div>
<div class="col-lg-2">
<p>
<input type="text" class="form-control">
</p>
</div>
<div class="col-lg-2">
<p>
<input type="text" class="form-control">
</p>
</div>
<div class="col-lg-2">
<p>
<input type="text" class="form-control">
</p>
</div>
<div class="col-lg-2">
<button type="submit" class="btn btn-default">Button</button>
</div>
</form>
</div>
#media (max-width: 992px) {
.collapse-class {
display: none;
}
}
You can do your on custom collapsing with a simple media query and css class. Simply toggle the CSS display from inline-block to block. Here, at 1000px and under, the two selects of the the second td will stack vertically; horizontally above 1000px.
CSS:
.collapse-it {
display: inline-block;
}
#media (max-width: 1000px) {
.collapse-it {
display:block;
}
.mobile-view:after {
content:"mobile view vertical stacking";
}
}
HTML:
<table style="border: 1px solid black;">
<tbody><tr>
<td style="border: 1px solid black;">
<div style="margin:5px;">credit card expiration</div>
</td>
<td style="border: 1px solid black;">
<div style="margin:5px;">
<div class="form-group collapse-it">
<select>
<option>a</option>
<option>b</option>
<option>c</option>
</select>
</div>
<div class="form-group collapse-it">
<select>
<option>d</option>
<option>e</option>
<option>f</option>
</select>
</div>
</div>
</td>
<td class="mobile-view" style="border: 1px solid black;"></td>
</tr>
</tbody></table>
View Demo on Bootply
If you just want it to go away at 992px but keep the button, put a class on what you want to collapse, and leave the button outside it. Then write a media query to display: none at 992px like so:
<form class="form-inline navbar-form collapse-class" name="bookerform" action="---" method="GET" target="_self">
<div class="form-group">hidden elements</div>
<div class="form-group">arrivo</div>
<div class="form-group">partenza</div>
<div class="form-group text-left"> Numero N</div>
<div class="form-group text-left"> Numero A</div>
<div class="form-group text-left"> Numero B</div>
<div class="form-group"> button check</div>
</form>
#media (max-width: 992px) {
.collapse-class {
display: none;
}
}
There may be a more elegant way to do this, but I'm having a hard time figuring out exactly what you want, so I'm trying to be general.

horizontal form css+bootstrap3 (border)

tell me how to do that would border separating INPUT did not reach the edge ?
i used to bootstrap3 Here is a layout:
<div class="input-group">
<span class="input-group-addon">#</span>
<input type="text" class="form-control" placeholder="username">
<input type="text" class="form-control" placeholder="e-mail">
<input type="text" class="form-control" placeholder="tel">
</div>
or can you tell me another solution ? thank you.
Bootstrap seems to add padding to the input-group class.
You could possibly override that using:
.input-group{
padding:0;
}
Or, you could scrap bootstrap (best thing you'll do to learn css), and create your own class:
.group {
background: blue;
padding-left: 20px;
position: relative;
}
.group:before {
position: absolute;
content: "#";
left: 0;
}
<div class="group">
<input type="text" class="form-control" placeholder="username">
<input type="text" class="form-control" placeholder="e-mail">
<input type="text" class="form-control" placeholder="tel">
</div>

Sky-Form/Bootstrap 3: How to render multiple inputs that make it looks like 1 large input?

I'm using sky-form library and bootstrap 3 to render my forms.
I have 3 inputs that I would like to wrap together.
I know that this requires custom css rules but I can't make it work as expected.
Please see attached image to better understand my need.
10x
Here's a start. You may want to fiddle with the focus highlights a bit.
http://jsfiddle.net/isherwood/vqkma/
<style>
.joined-left {
margin-right: -10px;
}
.joined-right {
margin-left: -10px;
border-left: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
</style>
<div class="form-group">
<label class="sr-only" for="exampleInputEmail2">Email address</label>
<input type="email" class="form-control joined-left" id="exampleInputEmail2" placeholder="Enter email" />
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword2">Password</label>
<input type="password" class="form-control joined-right" id="exampleInputPassword2" placeholder="Password" />
</div>

How to align column and rows in form

I have a form, and want that a row has 2 or 3 columns, to do so I am doing
.formcol {
float: left;
padding: 2px;
}
.formcol label {
font-weight: bold;
display:block;
}
how to get something like this
here is the fiddle
see i made following changes to your html strucutre:
<div class="formcol row">
<div class="formcol form-left middle">
<input type="text" id="col1x" size="12" name="col1x" />
<label for="col1x" >col1x</label>
</div>
<div class="formcol form-right middle">
<input type="text" id="col2x" size="12" name="col2x" />
<label for="col2x">col2x</label>
</div>
</div>
and added one extra class of mine :
.middle > label
{
text-align: center;
font-weight: bold;
font-size: 15px;
color: black;
}
and it works: fiddle
for 3 columns: make your structure like:
<div class="formcol row">
<div class="formcol form-left middle">
<input type="text" id="col1x" size="12" name="col1x" />
<label for="col1x" >col1x</label>
</div>
<div class="formcol form-left middle">
<input type="text" id="col1x" size="12" name="col1x" />
<label for="col1x" >col2x</label>
</div>
<div class="formcol form-right middle">
<input type="text" id="col2x" size="12" name="col2x" />
<label for="col2x">col3x</label>
</div>
</div>
(it uses all your existing class, plus one of mine)
Use CSS and HTML to float 2 or 3 div element blocks. Within each div section place your form input fields. Then simply remember to clear your floats when you are done.
Also within your CSS, control the height of each input field to be the same all around (i.e.
.my-input {
height:20px;
}
and associate the class name .my-input to every input field you have on the page.
This should visually give you the sense that there are rows of input fields due to the equal height of each field.