I would like the left side of the button flush with the textboxes. I'm using bootstrap 3 if that makes a difference. Here is my html code for the form. I can add my CSS if that's necessary as well. Thank you.
h1 {
font-size:83px;
}
.btn-primary {
background: #ffffff;
border-color: #ffffff;
color: #f05324;
}
.btn-default, .btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open > .dropdown-toggle.btn-default {
background: #ffffff;
border-color: #ffffff;
color: #f05324;
}
.panel-default {
border: none;
}
input[type="text"] {
color:white !important;
}
input[type="email"] {
color:white !important;
}
.model-content {
color:black !important;
}
.text-left {
text-align: left;
}
.text-right {
text-align: right;
}
.text-center {
text-align: center;
}
.navbar-default {
background-color: #000000;
}
body {
background: #f05324 !important;
margin-bottom: 80px;
color: #ffffff;
}
.page-header, .panel-body, .panel, .panel-default, .col-lg-9, .row {
background: #f05324 !important;
}
.form-control{
background-color: #f05324;
color: #000000;
}
hr {
border-color: #ffffff;
background-color: #ffffff;
color: #ffffff;
}
.link {
color: #ffffff;
}
.page-header {
margin-top: 0;
}
.panel-body {
padding-top: 0;
}
.img-featured {
margin-top : 15px;
margin-bottom: 15px;
margin-right : 15px;
}
.img-project{
margin-top : 15px;
margin-bottom: 15px;
}
.show-onclick {
display: none;
}
.show-onclick1 {
display: none;
}
.block {
position: absolute;
top: 0;
bottom: 0;
left: 50%;
margin-left: // half the width of your img
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<form class="form-horizontal" method="post" action="submit.php" enctype="multipart/form-data">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">NAME:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name" name="name">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">EMAIL:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="email" name="email">
</div>
</div>
<div class="form-group">
<label for="phoneNumber" class="col-sm-2 control-label">PHONE:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="phone" name="phone">
</div>
</div>
<div class="form-group">
<label for="major" class="col-sm-2 control-label">MAJOR:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="major" name="major">
</div>
</div>
<hr>
<div class="form-group">
<label for="itemForSale" class="col-sm-2 control-label">ITEM FOR SALE:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="itemForSale1" name="itemForSale1">
</div>
</div>
<div class="form-group">
<label for="quantity" class="col-sm-2 control-label">QUANTITY:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="quantity1" name="quantity1">
</div>
</div>
<div class="form-group">
<label for="price1" class="col-sm-2 control-label">PRICE:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="price1" name="price1">
</div>
</div>
<div class="form-group">
<label for="itemOneImg1" class="col-sm-2 control-label">IMAGE 1:</label>
<div class="col-sm-10">
<input type="file" accept=".jpg, .jpeg, .png" class="form-control" name="itemOneImg1">
</div>
</div>
<div class="form-group">
<label for="itemOneImg2" class="col-sm-2 control-label">IMAGE 2:</label>
<div class="col-sm-10">
<input type="file" accept=".jpg, .jpeg, .png" class="form-control" name="itemOneImg2">
</div>
</div>
<input id="additional-files" type="button" value="Additional Projects" class="btn btn-default">
</form>
If you want the left edge of the button to match up with the left edge of the text boxes then you just need to add an offset using the Bootstrap grid as follows:
<form class="form-horizontal" method="post" action="submit.php" enctype="multipart/form-data">
...
<div class="form-group">
<label for="itemOneImg2" class="col-sm-2 control-label">IMAGE 2:</label>
<div class="col-sm-10">
<input type="file" accept=".jpg, .jpeg, .png" class="form-control" name="itemOneImg2">
</div>
</div>
<div class="form-group">
<!-- Adjust col-sm-X for the buttons to adjust their positioning
Could also add btn-block class to make the button span the column -->
<div class="col-sm-offset-2 col-sm-9">
<input id="additional-files" type="button" value="Additional Projects" class="btn btn-default">
</div>
<div class="col-sm-1">
<input id="submit" type="button" value="Submit" class="btn btn-default">
</div>
</div>
</form>
More details (and another example) can be found on the Bootstrap website: http://getbootstrap.com/css/#forms-horizontal
EDIT: Based on additional information in comments.
Related
As the heading suggests, the required attribute is not working, so I cannot seem to be able to validate my form.
I am creating an event registration form.
I have tried encapsulating each element inside form,but that doesn't seem to work.
What can I do to help with that? Please excuse me if the question is childish. I am a beginner, and I am trying to practice as much as I can.
......................................................................................................................................................
<html>
<head>
<style>
* {
box-sizing: border-box;
}
text-danger {
color: #e74c3c;
}
input[type=text], select, textarea {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
resize: horizontal;
}
legend {
font: bold 1.0em Arial, Helvetica, sans-serif;
color: #00008B;
background-color: #FFFFFF;
}
label {
padding: 12px 12px 12px 0;
display: inline-block;
}
input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
float: right;
}
input[type=submit]:hover {
background-color: #45a049;
}
.container {
border-radius: 5px;
background-color: #f2f2f2;
padding: 20px;
}
fieldset {
border: 1px solid #61B5CF;
margin-top: 1.4em;
padding: 0.6em;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - when the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.col-25, .col-75, input[type=submit] {
width: 100%;
margin-top: 0;
}
}
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
input:not([type=submit]):invalid {
background-color: #ffdddd;
}
input:not([type=submit]):valid {
background-color: #ddffdd;
}
input:not([type=submit]):invalid:required {
background: #ffdddd url('http://www.developerdrive.com/wp-content/uploads/2013/08/asterisk1.png') no-repeat right top;
}
input:not([type=submit]):valid:required {
background: #ddffdd url('http://www.developerdrive.com/wp-content/uploads/2013/08/asterisk1.png') no-repeat right top;
}
input:not([type=submit]):optional {
background-color: #add1ef;
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
</style>
</head>
<body>
<div class="container">
<h2> WIE ILS'19 Registration</h2>
<form novalidate="">
<fieldset>
<legend>Login Details</legend>
<div class="form-group">
<label class="col-md-2 control-label">E-Mail</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
<input name="email" placeholder="E-Mail Address" class="form-control" type="text" required>
</div>
</div>
</div>
<br></br>
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label" >Password</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="password" name="password" id="password" onchange='check_pass();' required>
</div>
</div>
</div>
<br></br>
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label" >Confirm Password</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="password" name="confirm_password" id="confirm_password" onchange='check_pass();' required>
</div>
</div>
</div>
<br></br>
</form>
</fieldset>
<form>
<fieldset>
<legend>Personal Information</legend>
<form>
<div class="form-group">
<label class="col-xs-2 control-label">First Name</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="first_name" placeholder="First Name" class="form-control" type="text" required>
</div>
</div>
</div>
</form>
<br></br>
<!-- Text input-->
<form>
<div class="form-group">
<label class="col-xs-2 control-label" >Last Name</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="last_name" placeholder="Last Name" class="form-control" type="text" required>
</div>
</div>
</div>
</form>
<br></br>
<!-- Text input-->
<form>
<div class="form-group">
<label class="col-md-2 control-label">Contact No.</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span>
<input name="contact_no" placeholder="(+92)" class="form-control" type="text" required>
</div>
</div>
</div>
</form>
<br></br>
<form>
<div class="form-group">
<label class="col-md-2 control-label">CNIC No.</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="contact_no" placeholder="No-Hyphens" class="form-control" type="text" id="message" required>
<p class="help-block text-danger"></p>
</div>
</div>
</div>
</form>
<br></br>
</fieldset>
</form>
<form novalidate="">
<fieldset>
<legend>Education Details</legend>
<form>
<div class="form-group">
<label class="col-xs-2 control-label">University/Institute</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-education"></i></span>
<input name="first_name" placeholder="Institute Name" class="form-control" type="text" required>
</div>
</div>
</div>
</form>
<br></br>
<!-- Text input-->
<div class="form-group">
<label class="col-xs-2 control-label" >Degree Program </label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="last_name" placeholder="Last Name" class="form-control" type="text" required>
</div>
</div>
</div>
<br></br>
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label">Semester</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-tasks"></i></span>
<input name="contact_no" placeholder="" class="form-control" type="text" required>
</div>
</div>
</div>
<br></br>
</fieldset>
</form>
<form novalidate="">
<h5 style="font-weight:bold" >Do you need accomodation?</h5>
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
<br>
<br>
<button type="submit" name="submit" value="registration" id="submit" disabled>Submit</button>
</div>
</form>
<script >
function check_pass() {
if (document.getElementById('password').value ==
document.getElementById('confirm_password').value) {
document.getElementById('submit').disabled = false;
} else {
document.getElementById('submit').disabled = true;
}
}
</script>
</body>
</html>
In order for the submit to work, you need to put it inside of the form that you would like to submit. There are other ways of doing it, but that usually incorporates JavaScript and JQuery. The reason it is preventing you from submitting when it is inside the form though, is due to the novalidate attribute on the form. Just remove that and you should be good to go!
P.S. Even though the field is required on the front-end, that is all client side so it's not hard to go in and change it. It's always a good idea to validate it on the back-end as well. Think of the front-end as more of a suggestion and less of a final verdict.
I'm working on a project with a Bootstrap form. Very simply, I would like the form to have a scroll bar when the window is resized. I tried adding the overflow-auto class to my div, but that doesn't work for it. So when I resize my window, no scroll appears. Here's my code.
.form-container {
border-radius: 25px;
border: 1px solid black;
padding: 15px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.register-container { max-width: 500px; }
.title-header {
font-size: 25px;
font-weight: bold;
}
<div class="overflow-auto container form-container register-container">
<h1 class="title-header">REGISTER</h1>
<form id="register" method="post" action="register">
<?php writeMessageBoxIfMessage($message); ?>
<div class="form-group row">
<div class="col-sm-6">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">FIRST NAME</label> <br>
<input id="firstname" name="firstname" maxlength="80" required>
</div>
<div class="col-sm-6">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">LAST NAME</label> <br>
<input id="lastname" name="lastname" maxlength="80" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">EMAIL</label> <br>
<input type="email" id="email" name="email" maxlength="255" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">PASSWORD</label> <br>
<input type="password" id="password" name="password" maxlength="80" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">CONFIRM PASSWORD</label> <br>
<input type="password" id="confirm-password" name="confirm-password" maxlength="80" required>
</div>
<div class="col-sm-6">
Already have an account? <br> Click here</span> to login.
</div>
<div class="col-sm-6">
<input id="register" type="submit" name="submit"
value="REGISTER" />
</div>
</div>
</form>
</div>
Can anyone provide some suggestions so I can get this to scroll?
Can’t replicate this at the moment but try using
position: absolute;
and give a container
position: relative;
Rather than using the ‘fixed’ position.
Let me know if this doesn’t work.
I hope you want internal scroll if the form is more in height.
Use the following CSS,
Try it.
#register {
max-height: 200px;
overflow: scroll;
}
Please add media
#media (max-height: 420px) {
#register {
height: 150px;
overflow-x: hidden;
overflow-y: scroll;
}
}
for better solution and check your device height should be (max-height: yourDeviceHeight) in media
.form-container {
border-radius: 25px;
border: 1px solid black;
padding: 15px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.register-container { max-width: 500px; }
.title-header {
font-size: 25px;
font-weight: bold;
}
#media (max-height: 420px) {
#register {
height: 150px;
overflow-x: hidden;
overflow-y: scroll;
}
}
<div class="overflow-auto container form-container register-container">
<h1 class="title-header">REGISTER</h1>
<form id="register" method="post" action="register">
<?php writeMessageBoxIfMessage($message); ?>
<div class="form-group row">
<div class="col-sm-6">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">FIRST NAME</label> <br>
<input id="firstname" name="firstname" maxlength="80" required>
</div>
<div class="col-sm-6">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">LAST NAME</label> <br>
<input id="lastname" name="lastname" maxlength="80" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">EMAIL</label> <br>
<input type="email" id="email" name="email" maxlength="255" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">PASSWORD</label> <br>
<input type="password" id="password" name="password" maxlength="80" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">CONFIRM PASSWORD</label> <br>
<input type="password" id="confirm-password" name="confirm-password" maxlength="80" required>
</div>
<div class="col-sm-6">
Already have an account? <br> Click here</span> to login.
</div>
<div class="col-sm-6">
<input id="register" type="submit" name="submit"
value="REGISTER" />
</div>
</div>
</form>
</div>
I am making a form inside of jumbotron and for some reason I get it to look good on desktop view but when viewing it mobile it goes out of the jumbotron. I am using netbeans to do my coding. I even use #media (max-width: 620px). I tried using google but failed :(
#wrapper{
width: 500px;
height: 700px;
position: relative;
margin: 0 auto;
background-color: rgba(255,255,255,.75);
text-align: center;
}
form{
color: black;
text-align: center;
}
div{
clear: both;
}
#off{
background-color: rgba(225,0,0,.85);
color: white;
width: 525px;
height: 140px;
font-size: 1rem;
text-align: center;
}
.formHeader{
color: #104c8b;
}
.formFooter{
background-color: rgba(0,0,255,.5);
color: white;
margin: 65px 0 0 0;
}
#media(max-width: 620px) {
#wrapper{
width: 100px;
height: 100px;
position: relative;
margin: 0 auto;
background-color: rgba(255,255,255,.75);
text-align: center;
}
<section id="top" class="jumbotron">
<div class="container-fluid">
<div class="row text-center">
<div id="wrapper"><p>Contact Form</p>
<div class="formHeader">
</div>
<form action="test.html" method="get" name="test" id="myForm">
<label>Name</label><input name="name" type="text" /><br>
<label>Email</label><input name="email" type="text" /><br>
<label>Phone</label><input name="number" type="text" /><br>
<input type="submit" value="Send"/>
</form>
<div class="formFooter">
</div>
</div>
</div>
</div>
</section>
Given that you're using Bootstrap as a framework it seems a shame not to make use of all of well... the framework. With some restructuring of your HTML (to make use of Bootstrap's responsive classes and form controls) you can easily achieve the responsiveness you desire.
Most of it is just adding the necessary .col-*-* for grid layouts, and of course applying Bootstrap classes to your input and label elements, etc. An example Bootply is below though the code is significantly altered to better-reflect Bootstrap's Framework and modern input classifications (like tel or email, etc).
http://www.bootply.com/mPNCZyXbbD
The HTML:
<section id="top" class="jumbotron">
<div class="container-fluid">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="form-wrapper text-center">
<p>Contact Form</p>
<form action="test.html" method="get" name="test" id="myForm" class="form form-horizontal">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input name="name" type="text" class="form-control">
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input name="email" type="email" class="form-control">
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Phone</label>
<div class="col-sm-10">
<input name="number" type="tel" class="form-control">
</div>
</div>
<button type="submit" class="btn btn-default">Send</button>
</form>
</div>
</div>
</div>
</div>
</section>
And the CSS:
.form-wrapper {
padding: 15px;
background: rgba(255,255,255,0.75);
}
I'm building a simple horizontal form for contact information that includes a text area for notes. There is a significant amount of empty space to the left of my that text area that I want to move the address block up into. I can't figure out how to get the form-groups to overlap, or if that's even possible. I've tried putting all of the phone 2 fields and address fields in the same column and using <br> to separate the lines, but that definitely doesn't come out right. Here's the relevant code and screenshots of how the form-groups appear. Any tips would be greatly appreciated.
<html>
<body>
<?php require_once ("includes/php/header.php"); ?>
<div class="container-fluid">
<form id="newContact" action="newContact.php" method="POST" class="form-horizontal">
<div class="form-group">
<div class="col-md-1 col-md-offset-1">
<label class="control-label">
Vendor
</label>
</div>
<div class="col-md-2">
<select name="vendID" class="form-control">
<option disabled selected value=""> - select a vendor - </option>
<?php
$result = vendorDB::getInstance()->vendorList();
while ($row= mysqli_fetch_array($result)):
?>
<option value="<?php echo $row["VEND_ID"];?>"><?php echo $row["VEND_NAME"];?></option>
<?php
endwhile;
mysqli_free_result($result);
?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-1 col-md-offset-1">
<label class="control-label twoline-label">
First Name
</label>
</div>
<div class="col-md-2">
<input type="text" name="contFirst" class="form-control" />
</div>
<div class="col-md-1">
<label class="control-label twoline-label">
Last<br/>Name
</label>
</div>
<div class="col-md-2">
<input type="text" name="contLast" class="form-control" />
</div>
<div class="col-md-1">
<label class="control-label twoline-label">
E-mail Address
</label>
</div>
<div class="col-md-3">
<div class="input-group">
<span class="input-group-addon">#</span>
<input type="email" name="contEmail" class="form-control" />
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-1 col-md-offset-1">
<label class="control-label" style="padding-top: 7px">
Phone 1
</label>
</div>
<div class="col-md-2">
<div class="input-group">
<span class="input-group-addon glyphicon glyphicon-phone-alt"></span>
<input type="text" name="contPhone1" class="form-control" placeholder="555-555-5555" />
</div>
</div>
<div class="col-md-1">
<select name="contPhone1Type" class="form-control">
</select>
</div>
<div class="col-md-1">
<label class="control-label">
Notes
</label>
</div>
</div>
<div class="form-group">
<div class="col-md-1 col-md-offset-1">
<label class="control-label" style="padding-top: 7px">
Phone 2
</label>
</div>
<div class="col-md-2">
<div class="input-group">
<span class="input-group-addon glyphicon glyphicon-phone-alt"></span>
<input type="text" name="contPhone2" class="form-control" placeholder="555-555-5555" />
</div>
</div>
<div class="col-md-1" >
<select name="contPhone2Type" class="form-control">
</select>
</div>
<div class="col-md-6">
<textarea form="newContact" name="contNote" class="form-control"
rows="11" style="resize: none" placeholder="(optional)"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-md-4 col-md-offset-1">
<label class="control-label">
Address
</label>
</div>
</div>
<div class="form-group">
<div class="col-md-4 col-md-offset-1">
<input type="text" name="contAddr1" class="form-control" />
</div>
</div>
<div class="form-group">
<div class="col-md-4 col-md-offset-1">
<input type="text" name="contAddr2" class="form-control" />
</div>
</div>
<div class="form-group">
<div class="col-md-2 col-md-offset-1">
<label class="control-label">
City
</label>
</div>
<div class="col-md-1">
<label class="control-label">
State
</label>
</div>
<div class="col-md-2">
<label class="control-label">
ZIP
</label>
</div>
</div>
<div class="form-group">
<div class="col-md-2 col-md-offset-1">
<input type="text" name="contAddrCity" class="form-control" />
</div>
<div class="col-md-1">
<select name="contAddrState" class="form-control">
</select>
</div>
<div class="col-md-1">
<input type="text" name="contAddrZip" class="form-control" />
</div>
</div>
<div class="form-group">
</div>
<div class="form-group">
</div>
<div class="form-group">
<div class="col-md-2 col-md-offset-3">
<span class="icon-input-btn">
<span class="glyphicon glyphicon-ok"></span>
<input type="submit" class="form-control btn btn-primary" value="Save New Contact"/>
</span>
</div>
<div class="col-md-2 col-md-offset-3">
<span class="input-group-btn">
<span class="icon-input-btn">
<span class="glyphicon glyphicon-repeat"></span>
<input type="reset" class="form-control btn btn-default" value="Reset" />
</span>
</span>
</div>
</div>
</form>
</div>
</body>
Phone 2/Text area form-group
First form-group of address block
CSS
td,
th{
text-align: left;
}
.nav-tabs{
margin-bottom: 20px;
}
.nav-tabs > li {
float: left;
margin-bottom: -1px;
}
.nav-tabs > li > a{
color: black;
border-top-color: #ccc;
border-right-color: #ccc;
}
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
border-color: #ccc;
border-bottom-color: transparent;
}
.ui-datepicker select.ui-datepicker-month,
.ui-datepicker select.ui-datepicker-year{
color: white;
background-color: black;
}
.navbar-inverse .navbar-nav > li > a {
color: #fff;
}
.navbar-inverse .navbar-nav > li > a:hover,
.navbar-inverse .navbar-nav > li > a:focus {
color: #fff;
background-color: #6a6a6a;
}
.error{
color: #c00;
font-size: 125%;
}
.icon-input-btn{
display: inline-block;
position: relative;
}
.icon-input-btn input[type="submit"]{
padding-left: 2em;
}
.icon-input-btn input[type="reset"]{
padding-left: 2em;
}
.icon-input-btn .glyphicon{
display: inline-block;
position: absolute;
left: 0.65em;
top: 30%;
}
.tableheader{
border-color: black;
border-style: solid;
border-width: 0 1px 0 1px;
background-color: #D8D8D8;
font-weight: bold
}
.glyphicon{
top: 0px;
}
.form-horizontal .control-label{
display: inline-block;
vertical-align: middle;
float: none;
text-align: left;
padding-top: 0px;
}
.form-horizontal .controls {
display: inline-block;
margin-left: 20px;
}
To achieve your expected result , i have used div with class address, enclosing address fields and position:relative with top
.address{
position:relative;
top:-205px;
}
http://codepen.io/nagasai/pen/NAaNkK
HTML:
<html>
<body>
<?php require_once ("includes/php/header.php"); ?>
<div class="container-fluid">
<form id="newContact" action="newContact.php" method="POST" class="form-horizontal">
<div class="form-group">
<div class="col-md-1 col-md-offset-1">
<label class="control-label">
Vendor
</label>
</div>
<div class="col-md-2">
<select name="vendID" class="form-control">
<option disabled selected value=""> - select a vendor - </option>
<?php
$result = vendorDB::getInstance()->vendorList();
while ($row= mysqli_fetch_array($result)):
?>
<option value="<?php echo $row["VEND_ID"];?>"><?php echo $row["VEND_NAME"];?></option>
<?php
endwhile;
mysqli_free_result($result);
?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-1 col-md-offset-1">
<label class="control-label twoline-label">
First Name
</label>
</div>
<div class="col-md-2">
<input type="text" name="contFirst" class="form-control" />
</div>
<div class="col-md-1">
<label class="control-label twoline-label">
Last<br/>Name
</label>
</div>
<div class="col-md-2">
<input type="text" name="contLast" class="form-control" />
</div>
<div class="col-md-1">
<label class="control-label twoline-label">
E-mail Address
</label>
</div>
<div class="col-md-3">
<div class="input-group">
<span class="input-group-addon">#</span>
<input type="email" name="contEmail" class="form-control" />
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-1 col-md-offset-1">
<label class="control-label" style="padding-top: 7px">
Phone 1
</label>
</div>
<div class="col-md-2">
<div class="input-group">
<span class="input-group-addon glyphicon glyphicon-phone-alt"></span>
<input type="text" name="contPhone1" class="form-control" placeholder="555-555-5555" />
</div>
</div>
<div class="col-md-1">
<select name="contPhone1Type" class="form-control">
</select>
</div>
<div class="col-md-1">
<label class="control-label">
Notes
</label>
</div>
</div>
<div class="form-group">
<div class="col-md-1 col-md-offset-1">
<label class="control-label" style="padding-top: 7px">
Phone 2
</label>
</div>
<div class="col-md-2">
<div class="input-group">
<span class="input-group-addon glyphicon glyphicon-phone-alt"></span>
<input type="text" name="contPhone2" class="form-control" placeholder="555-555-5555" />
</div>
</div>
<div class="col-md-1" >
<select name="contPhone2Type" class="form-control">
</select>
</div>
<div class="col-md-6">
<textarea form="newContact" name="contNote" class="form-control"
rows="11" style="resize: none" placeholder="(optional)"></textarea>
</div>
</div>
<div class="address">
<div class="form-group">
<div class="col-md-4 col-md-offset-1">
<label class="control-label">
Address
</label>
</div>
</div>
<div class="form-group">
<div class="col-md-4 col-md-offset-1">
<input type="text" name="contAddr1" class="form-control" />
</div>
</div>
<div class="form-group">
<div class="col-md-4 col-md-offset-1">
<input type="text" name="contAddr2" class="form-control" />
</div>
</div>
<div class="form-group">
<div class="col-md-2 col-md-offset-1">
<label class="control-label">
City
</label>
</div>
<div class="col-md-1">
<label class="control-label">
State
</label>
</div>
<div class="col-md-2">
<label class="control-label">
ZIP
</label>
</div>
</div>
<div class="form-group">
<div class="col-md-2 col-md-offset-1">
<input type="text" name="contAddrCity" class="form-control" />
</div>
<div class="col-md-1">
<select name="contAddrState" class="form-control">
</select>
</div>
<div class="col-md-1">
<input type="text" name="contAddrZip" class="form-control" />
</div>
</div>
<div class="form-group">
</div>
<div class="form-group">
</div>
<div class="form-group">
<div class="col-md-2 col-md-offset-3">
<span class="icon-input-btn">
<span class="glyphicon glyphicon-ok"></span>
<input type="submit" class="form-control btn btn-primary" value="Save New Contact"/>
</span>
</div>
</div>
<div class="col-md-2 col-md-offset-3">
<span class="input-group-btn">
<span class="icon-input-btn">
<span class="glyphicon glyphicon-repeat"></span>
<input type="reset" class="form-control btn btn-default" value="Reset" />
</span>
</span>
</div>
</div>
</form>
</div>
</body>
CSS:
td,
th{
text-align: left;
}
.nav-tabs{
margin-bottom: 20px;
}
.nav-tabs > li {
float: left;
margin-bottom: -1px;
}
.nav-tabs > li > a{
color: black;
border-top-color: #ccc;
border-right-color: #ccc;
}
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
border-color: #ccc;
border-bottom-color: transparent;
}
.ui-datepicker select.ui-datepicker-month,
.ui-datepicker select.ui-datepicker-year{
color: white;
background-color: black;
}
.navbar-inverse .navbar-nav > li > a {
color: #fff;
}
.navbar-inverse .navbar-nav > li > a:hover,
.navbar-inverse .navbar-nav > li > a:focus {
color: #fff;
background-color: #6a6a6a;
}
.error{
color: #c00;
font-size: 125%;
}
.icon-input-btn{
display: inline-block;
position: relative;
}
.icon-input-btn input[type="submit"]{
padding-left: 2em;
}
.icon-input-btn input[type="reset"]{
padding-left: 2em;
}
.icon-input-btn .glyphicon{
display: inline-block;
position: absolute;
left: 0.65em;
top: 30%;
}
.tableheader{
border-color: black;
border-style: solid;
border-width: 0 1px 0 1px;
background-color: #D8D8D8;
font-weight: bold
}
.glyphicon{
top: 0px;
}
.form-horizontal .control-label{
display: inline-block;
vertical-align: middle;
float: none;
text-align: left;
padding-top: 0px;
}
.form-horizontal .controls {
display: inline-block;
margin-left: 20px;
}
.address{
position:relative;
top:-205px;
}
Hope this works for you
Trying to put three of my first forms in the center of the container and put the last two forms next to the first three. Trying to use float, but that didn't work.
Any help is much appricieted:
bootply: http://www.bootply.com/125841
How I want it to look:
Ok.
you put everything inside a div with class="everything".
.everything {
overflow: auto;
width: 600px;
margin-left:auto;
margin-right:auto;
}
then you put the first three group of textfields in a class called .blocks and the other three groups of textfields and button in another div called .blocks too.
.blocks {
width: 50%;
float:left;
}
here you are fella:
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-lg-12">
<form class="form-horizontal" role="form">
<div class="block">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-2">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
<div class="col-sm-2">
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password1</label>
<div class="col-sm-2">
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
</div>
<div class="block">
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password2</label>
<div class="col-sm-2">
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password3</label>
<div class="col-sm-2">
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<button id="onlyButton" type="submit" class="btn btn-default">Sign in</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
css:
.jumbotron {
/* display: inline-block; */
margin-bottom: auto;
margin: 0 auto;
min-height: 623px;
}
.block {
width: 50%;
float: left;
}
.container {
min-height: 530px;
/* set border styling */
border-color: black;
border-style: solid;
border-width: 1px;
width: 600px;
margin-right:auto;
margin-left:auto;
overflow:auto;
/* set border roundness */
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
margin: 0 auto;
width: 800px;
/* display: inline-block; */
background-color: white;
}
.form-horizontal {
padding-right: 150px;
}
.form-control {
width: 100px;
margin-left: 30px;
}
#onlyButton {
float:right;
}