I am trying to upgrade this multi step form so the back and next buttons sit in the footer of this modal. How do I go about moving them there? (i.e. the next button in RED) - It doesn't work clicking this.
Thank you
$(document).ready(function() {
var navListItems = $('div.setup-panel div a'),
allWells = $('.setup-content'),
allNextBtn = $('.nextBtn'),
allPrevBtn = $('.prevBtn');
allWells.hide();
navListItems.click(function(e) {
e.preventDefault();
var $target = $($(this).attr('href')),
$item = $(this);
if (!$item.hasClass('disabled')) {
navListItems.removeClass('btn-primary').addClass('btn-default');
$item.addClass('btn-primary');
allWells.hide();
$target.show();
$target.find('input:eq(0)').focus();
}
});
allPrevBtn.click(function() {
var curStep = $(this).closest(".setup-content"),
curStepBtn = curStep.attr("id"),
prevStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().prev().children("a");
prevStepWizard.trigger('click');
});
allNextBtn.click(function() {
var curStep = $(this).closest(".setup-content"),
curStepBtn = curStep.attr("id"),
nextStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().next().children("a"),
curInputs = curStep.find("input[type='text'],input[type='url']"),
isValid = true;
$(".form-group").removeClass("has-error");
for (var i = 0; i < curInputs.length; i++) {
if (!curInputs[i].validity.valid) {
isValid = false;
$(curInputs[i]).closest(".form-group").addClass("has-error");
}
}
if (isValid)
nextStepWizard.removeAttr('disabled').trigger('click');
});
$('div.setup-panel div a.btn-primary').trigger('click');
});
body {
margin-top: 40px;
}
.stepwizard-step p {
margin-top: 10px;
}
.stepwizard-row {
display: table-row;
}
.stepwizard {
display: table;
width: 90%;
position: relative;
}
.stepwizard-step button[disabled] {
opacity: 1 !important;
filter: alpha(opacity=100) !important;
}
.stepwizard-row:before {
top: 14px;
bottom: 0;
position: absolute;
content: " ";
width: 100%;
height: 1px;
background-color: #ccc;
z-order: 0;
}
.stepwizard-step {
display: table-cell;
text-align: center;
position: relative;
}
.btn-circle {
width: 30px;
height: 30px;
text-align: center;
padding: 6px 0;
font-size: 12px;
line-height: 1.428571429;
border-radius: 15px;
}
.modal-body {
max-height: calc(100vh - 210px);
overflow-y: auto;
}
.modal-dialog {
min-width: 70%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div class="stepwizard">
<div class="stepwizard-row setup-panel">
<div class="stepwizard-step">
1
<p>Student Details</p>
</div>
<div class="stepwizard-step">
2
<p>Student Medical</p>
</div>
<div class="stepwizard-step">
3
<p>Primary Contact</p>
</div>
<div class="stepwizard-step">
4
<p>Secondary Contact</p>
</div>
<div class="stepwizard-step">
5
<p>Review & Submit</p>
</div>
</div>
</div>
</div>
<div class="modal-body">
<div class="container" style="width:100%;">
<form role="form" action="" method="post">
<div class="row setup-content" id="step-1">
<div class="col-md-6 col-md-offset-3">
<div class="col-md-12">
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button">Next</button>
<h3> Step 1</h3>
<div class="form-group">
<label class="control-label">First Name</label>
<input maxlength="100" required="required" class="form-control" placeholder="Enter First Name" type="text">
</div>
<div class="form-group">
<label class="control-label">Last Name</label>
<input maxlength="100" required="required" class="form-control" placeholder="Enter Last Name" type="text">
</div>
<div class="form-group">
<label class="control-label">Address</label>
<textarea required="required" class="form-control" placeholder="Enter your address"></textarea>
</div>
</div>
</div>
</div>
<div class="row setup-content" id="step-2">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 2</h3>
<div class="form-group">
<label class="control-label">Company Name</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Name" type="text">
</div>
<div class="form-group">
<label class="control-label">Company Address</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Address" type="text">
</div>
<button class="btn btn-primary prevBtn btn-lg pull-left" type="button">Back</button>
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button">Next</button>
</div>
</div>
</div>
<div class="row setup-content" id="step-3">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 3</h3>
<div class="form-group">
<label class="control-label">Company Name</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Name" type="text">
</div>
<div class="form-group">
<label class="control-label">Company Address</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Address" type="text">
</div>
<button class="btn btn-primary prevBtn btn-lg pull-left" type="button">Back</button>
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button">Next</button>
</div>
</div>
</div>
<div class="row setup-content" id="step-4">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 4</h3>
<div class="form-group">
<label class="control-label">Company Name</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Name" type="text">
</div>
<div class="form-group">
<label class="control-label">Company Address</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Address" type="text">
</div>
<button class="btn btn-primary prevBtn btn-lg pull-left" type="button">Back</button>
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button">Next</button>
</div>
</div>
</div>
<div class="row setup-content" id="step-5">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 5</h3>
<button class="btn btn-primary prevBtn btn-lg pull-left" type="button">Back</button>
<button class="btn btn-success btn-lg pull-right" type="submit">Submit</button>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
<button class="btn btn-primary prevBtn btn-lg pull-left" type="button">Back</button>
<button style="color:red;" class="btn btn-primary nextBtn btn-lg pull-right" type="button">Next</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
Now your prev and next buttons are working
$(document).ready(function () {
var navListItems = $('div.setup-panel div a'),
allWells = $('.setup-content'),
allNextBtn = $('.nextBtn'),
allPrevBtn = $('.prevBtn');
allWells.hide();
navListItems.click(function (e) {
e.preventDefault();
var $target = $($(this).attr('href')),
$item = $(this);
if (!$item.hasClass('disabled')) {
navListItems.removeClass('btn-primary').addClass('btn-default');
$item.addClass('btn-primary');
allWells.hide();
$target.show();
$target.find('input:eq(0)').focus();
}
});
allPrevBtn.click(function(){
var setupwizard = $('.stepwizard-row');
var sel = setupwizard.find('.btn-primary');
var to_sel = sel.parent().prev().find('.btn-circle');
to_sel.trigger('click');
/* DISABLING AND ENABLING PREV AND NEXT
BUTTONS BASED ON CURRENT PAGE
*/
if(to_sel.hasClass('start-class'))
{
$('.prevBtn').addClass('disabled-control');
$('.nextBtn').removeClass('disabled-control');
}
else if(to_sel.hasClass('end-class'))
{
$('.nextBtn').addClass('disabled-control');
$('.prevBtn').removeClass('disabled-control');
}
else
{
$('.nextBtn').removeClass('disabled-control');
$('.prevBtn').removeClass('disabled-control');
}
});
$(document).on('click', '.nextBtn', function(){
var setupwizard = $('.stepwizard-row');
var sel = setupwizard.find('.btn-primary');
var to_sel = sel.parent().next().find('.btn-circle');
var err = 0;
var step = get_current_page_id();
/* CHECKING IF ALL INPUTS AND TEXTAREA IN THE CURRENT
PAGE ARE FILLED. IF NOT : ADD ERROR CLASS ON INPUT
AND INCREMENT ERROR COUNTER */
$('#' + step + ' input, textarea').each(function(){
if($(this).val() == '')
{
if(!$(this).hasClass('error-class'))
$(this).addClass('error-class')
err++;
}
else
{
if($(this).hasClass('error-class'))
$(this).removeClass('error-class')
}
});
/* IF ERROR COUNTER == 0 ( ie. NO ERRORS FOUND )
=> PROCEED TO NEXT STEP
*/
if(err == 0)
{
to_sel.trigger('click');
if(to_sel.hasClass('start-class'))
{
$('.prevBtn').addClass('disabled-control');
$('.nextBtn').removeClass('disabled-control');
}
else if(to_sel.hasClass('end-class'))
{
$('.nextBtn').addClass('disabled-control');
$('.prevBtn').removeClass('disabled-control');
}
else
{
$('.nextBtn').removeClass('disabled-control');
$('.prevBtn').removeClass('disabled-control');
}
}
});
/* SHOW AND HIDE ERROR CLASS AS USER TYPES */
$(document).on('input', 'input, textarea', function(){
if($(this).val() == '')
{
if(!$(this).hasClass('error-class'))
$(this).addClass('error-class');
}
else
{
if($(this).hasClass('error-class'))
$(this).removeClass('error-class')
}
});
/* FUNCTION WHICH RETURNS THE ID OF CURRENT VISIBLE PAGE */
function get_current_page_id()
{
return $(".setup-content:visible").attr('id');
}
$('div.setup-panel div a.btn-primary').trigger('click');
});
body {
margin-top:40px;
}
.stepwizard-step p {
margin-top: 10px;
}
.stepwizard-row {
display: table-row;
}
.stepwizard {
display: table;
width: 90%;
position: relative;
}
.stepwizard-step button[disabled] {
opacity: 1 !important;
filter: alpha(opacity=100) !important;
}
.stepwizard-row:before {
top: 14px;
bottom: 0;
position: absolute;
content: " ";
width: 100%;
height: 1px;
background-color: #ccc;
z-order: 0;
}
.stepwizard-step {
display: table-cell;
text-align: center;
position: relative;
}
.btn-circle {
width: 30px;
height: 30px;
text-align: center;
padding: 6px 0;
font-size: 12px;
line-height: 1.428571429;
border-radius: 15px;
}
.modal-body {
max-height: calc(100vh - 210px);
overflow-y: auto;
}
.disabled-control{
opacity: 0.4;
cursor: not-allowed;
pointer-events: none;
}
.modal-dialog {
min-width: 70%;
}
.error-class{
border: 1px solid red !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div class="stepwizard">
<div class="stepwizard-row setup-panel">
<div class="stepwizard-step">
1
<p>Student Details</p>
</div>
<div class="stepwizard-step">
2
<p>Student Medical</p>
</div>
<div class="stepwizard-step">
3
<p>Primary Contact</p>
</div>
<div class="stepwizard-step">
4
<p>Secondary Contact</p>
</div>
<div class="stepwizard-step">
5
<p>Review & Submit</p>
</div>
</div>
</div>
</div>
<div class="modal-body">
<div class="container" style="width:100%;">
<form role="form" action="" method="post">
<div class="row setup-content" id="step-1">
<div class="col-md-6 col-md-offset-3">
<div class="col-md-12">
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button">Next</button><h3> Step 1</h3>
<div class="form-group">
<label class="control-label">First Name</label>
<input maxlength="100" required="required" class="form-control" placeholder="Enter First Name" type="text">
</div>
<div class="form-group">
<label class="control-label">Last Name</label>
<input maxlength="100" required="required" class="form-control" placeholder="Enter Last Name" type="text">
</div>
<div class="form-group">
<label class="control-label">Address</label>
<textarea required="required" class="form-control" placeholder="Enter your address"></textarea>
</div>
</div>
</div>
</div>
<div class="row setup-content" id="step-2">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 2</h3>
<div class="form-group">
<label class="control-label">Company Name</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Name" type="text">
</div>
<div class="form-group">
<label class="control-label">Company Address</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Address" type="text">
</div>
<button class="btn btn-primary prevBtn btn-lg pull-left disabled-control" type="button">Back</button>
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button">Next</button>
</div>
</div>
</div>
<div class="row setup-content" id="step-3">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 3</h3>
<div class="form-group">
<label class="control-label">Company Name</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Name" type="text">
</div>
<div class="form-group">
<label class="control-label">Company Address</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Address" type="text">
</div>
<button class="btn btn-primary prevBtn btn-lg pull-left disabled-control" type="button">Back</button>
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button">Next</button>
</div>
</div>
</div>
<div class="row setup-content" id="step-4">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 4</h3>
<div class="form-group">
<label class="control-label">Company Name</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Name" type="text">
</div>
<div class="form-group">
<label class="control-label">Company Address</label>
<input maxlength="200" required="required" class="form-control" placeholder="Enter Company Address" type="text">
</div>
<button class="btn btn-primary prevBtn btn-lg pull-left disabled-control" type="button">Back</button>
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button">Next</button>
</div>
</div>
</div>
<div class="row setup-content" id="step-5">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3> Step 5</h3>
<button class="btn btn-primary prevBtn btn-lg pull-left disabled-control" type="button">Back</button>
<button class="btn btn-success btn-lg pull-right" type="submit">Submit</button>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
<button class="btn btn-primary prevBtn btn-lg pull-left disabled-control" type="button">Back</button>
<button style="color:red;" class="btn btn-primary nextBtn btn-lg pull-right" type="button">Next</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
Related
I am trying to create a form which should show an alert:
When hitting the button control next to the input control, it should show an alert. The alert appears correctly, however, the input controls following after shuffle to a wrong location:
I would like to see the following happen:
How could I prevent the shuffling of input controls on the left to the right side? Keep in mind that in the solution I would like the order of input controls to be the same when resizing to smaller screen size.
This is what I tried so far in code:
function toggleInfo(ele) {
if (ele.style.display === "none") {
ele.style.display = "block";
} else {
ele.style.display = "none";
}
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<div class="col-md-6">
<div class="form-group">
<label>One</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default" onclick="toggleInfo(foo_id)">
-
</button>
</div>
</div>
</div>
<div class="alert alert-info" style="display: none;" id="foo_id">
<strong>Info: </strong> Message.
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Two</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Three</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Four</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Five</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
I tried wrapping up every two col-md-6 elements in a <div> element to see if these would keep sticking together. This was not the case:
function toggleInfo(ele) {
if (ele.style.display === "none") {
ele.style.display = "block";
} else {
ele.style.display = "none";
}
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<div><!-- Not working -->
<div class="col-md-6">
<div class="form-group">
<label>One</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default" onclick="toggleInfo(foo_id)">
-
</button>
</div>
</div>
</div>
<div class="alert alert-info" style="display: none;" id="foo_id">
<strong>Info: </strong> Message.
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Two</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
</div><!-- End of change I tried -->
<div class="col-md-6">
<div class="form-group">
<label>Three</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Four</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Five</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
What could I do to fix this problem?
You are missing row class and also you required to update your DOM check snippet.
function toggleInfo(ele) {
if (ele.style.display === "none") {
ele.style.display = "block";
} else {
ele.style.display = "none";
}
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<div class="row">
<!-- Not working -->
<div class="col-md-6">
<div class="form-group">
<label>One</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default" onclick="toggleInfo(foo_id)">
-
</button>
</div>
</div>
</div>
<div class="alert alert-info" style="display: none;" id="foo_id">
<strong>Info: </strong> Message.
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Two</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
</div>
<!-- End of change I tried -->
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Three</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Four</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Five</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
</div>
u need to wrap 2 col-md-6 divs in a row like this:
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>One</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default" onclick="toggleInfo(foo_id)">
-
</button>
</div>
</div>
</div>
<div class="alert alert-info" style="display: none;" id="foo_id">
<strong>Info: </strong> Message.
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Two</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
You should place <div class="container-fluid"><div class="row" /></div></div> as parent to your child <div class="col-md-6" />
The important part is <div class="row"> /*child col */</div>
See sample snippets below:
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>One</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default" onclick="toggleInfo(foo_id)">
-
</button>
</div>
</div>
</div>
<div class="alert alert-info" style="display: none;" id="foo_id">
<strong>Info: </strong> Message.
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Two</label>
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default">
-
</button>
</div>
</div>
</div>
</div>
</div>
Tweak here: https://codepen.io/kenneth-bolico/pen/oNvmdRo
How can I do it so that the label and input elements are placed on the same row? Can anyone help me with this?
.entry:not(:first-of-type) {
margin-top: 10px;
}
.glyphicon {
font-size: 12px;
}
<div class="container">
<div class="row">
<div class="control-group" id="fields">
<label class="control-label" for="field1">Nice Multiple Form Fields</label>
<div class="controls">
<form role="form" autocomplete="off">
<div class="entry input-group col-xs-3">
<input class="form-control" name="fields[]" placeholder="Type something">
<span class="input-group-btn">
<button class="btn btn-success btn-add" type="button">
<span class="glyphicon glyphicon-plus"></span>
</button>
</span>
</div>
</form>
</div>
</div>
</div>
</div>
The for attribute of the tag should be equal to the id attribute of the related element to bind them together, however you don't have id in your input div..
try add this :
<input class="form-control" id="field1" name="fields[]" type="text" placeholder="Type something" />
Just place the label above the input element since both are inline elements by default:
.entry:not(:first-of-type) {
margin-top: 10px;
}
.glyphicon {
font-size: 12px;
}
<div class="container">
<div class="row">
<div class="control-group" id="fields">
<div class="controls">
<form role="form" autocomplete="off">
<div class="entry input-group col-xs-3">
<label class="control-label" for="field1">Nice Multiple Form Fields</label>
<input class="form-control" name="fields[]" type="text" placeholder="Type something">
<span class="input-group-btn">
<button class="btn btn-success btn-add" type="button">
<span class="glyphicon glyphicon-plus"></span>
</button>
</span>
</div>
</form>
</div>
</div>
</div>
</div>
I've had a block 'jumbotron' it has next css parameters:
.jumbotron {
position: absolute;
top: 50%;
left:50%;
transform: translate(-50%,-50%);
background: rgba(0, 0, 0, 0.7);
border-radius: 20px;
}
It's looks so good in the centre of window. But now I want put "container button-block"on that. With next css parameters it looks great too..
.button-block {
position: absolute;
top: 5%;
left: 36%;
}
But if I try to change windows size my 'button-block' is starting to dance and brakes design. How can I stick these buttons to jumbotron block What decision will more common?
.jumbotron {
position: absolute;
top: 50%;
left:50%;
transform: translate(-50%,-50%);
background: rgba(0, 0, 0, 0.7);
border-radius: 20px;
}
.button-block {
position: absolute;
top: 5%;
left: 36%;
}
<div class="page-header" style="background-image: url('../assets/img/background_presentation.jpg');">
<div class="container button-block">
<button type="button" class="btn btn-default btn-circle btn-xl active">1</button>
<button type="button" class="btn btn-default btn-circle btn-xl">2</button>
<button type="button" class="btn btn-default btn-circle btn-xl">3</button>
</div>
<div class="container">
<header class="jumbotron">
<h2 class="text-center text-white header">What is the property Address</h2>
<form>
<div class="form-group">
<label for="inputAddress" class="text-white">Address</label>
<input type="text" class="form-control" id="inputAddress">
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputCity" class="text-white">City</label>
<input type="text" class="form-control" id="inputCity">
</div>
<div class="form-group col-md-6">
<label for="inputZip" class="text-white">Zip</label>
<input type="text" class="form-control" id="inputZip">
</div>
</div>
<div class="col-md-12 text-center block-buttons">
<button type="submit" class="btn btn-neutral btn-lg">Continue</button>
</div>
</form>
</header>
</div>
</div>
Something like this?
.container{text-align: center;}
.jumbotron {
position: relative;
top: 50%;
display: inline-block;
margin-top: 25%;
/*transform: translate(-50%,-50%);*/
background: rgba(0, 0, 0, 0.7);
border-radius: 20px;
}
.button-block {
position: absolute;
top: -22px;
left: 36%;
}
<div class="page-header" style="background-image: url('../assets/img/background_presentation.jpg');">
<div class="container">
<header class="jumbotron">
<div class="container button-block">
<button type="button" class="btn btn-default btn-circle btn-xl active">1</button>
<button type="button" class="btn btn-default btn-circle btn-xl">2</button>
<button type="button" class="btn btn-default btn-circle btn-xl">3</button>
</div>
<h2 class="text-center text-white header">What is the property Address</h2>
<form>
<div class="form-group">
<label for="inputAddress" class="text-white">Address</label>
<input type="text" class="form-control" id="inputAddress">
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputCity" class="text-white">City</label>
<input type="text" class="form-control" id="inputCity">
</div>
<div class="form-group col-md-6">
<label for="inputZip" class="text-white">Zip</label>
<input type="text" class="form-control" id="inputZip">
</div>
</div>
<div class="col-md-12 text-center block-buttons">
<button type="submit" class="btn btn-neutral btn-lg">Continue</button>
</div>
</form>
</header>
</div>
</div>
I'm working in designing Login/SignUp page with animation.
Below is the link which I want exactly but I'm not sure which control they have used.
UPDATED SITE:
Like here
I have added simple way so that you can do it easily.
You have to do formatting by your side but I have already covered almost all the possibility.
Just for the modal refer this link. Which helps you in creating your modal dynamically rather then writing conventional code.
var Loginpage = function() {};
Loginpage.showHideContent = function(id) {
if (id == 1) {
$('#signup-div').show();
$('#login-div').hide();
} else if (id == 2) {
$('#signup-div').hide();
$('#login-div').show();
}
}
Loginpage.showLogin = function(id) {
if (id != undefined && id != null) {
Loginpage.showHideContent(id);
}
var shown_div = $('#signup_login_container');
BootstrapDialog.show({
title: '<img src="https://cdn0.iconfinder.com/data/icons/Pinterest/512/Pinterest_Favicon.png" height="20px" />',
message: $('#signup_login_container'),
closeByBackdrop: false,
onshown: function(dialog) {
dialog.setSize(BootstrapDialog.SIZE_SMALL);
},
onhide: function() {
$('#hidden-div').append(shown_div);
}
});
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/css/bootstrap-dialog.min.css" />
<button class="btn btn-danger" onclick="Loginpage.showLogin(1)">Sign Up</button>
<button class="btn btn-default" onclick="Loginpage.showLogin(2)">Log in</button>
<div id="hidden-div" style="display : none">
<div class="container-fluid" id="signup_login_container" style="padding :0px 0px">
<div id="login-div" style="display : none">
<h3 align="center">Log in to see more</h3>
<br>
<button type="button" class="btn btn-default btn-block">Continue With Facebook</button>
<button type="button" class="btn btn-default btn-block">Login With Google</button>
<hr>
<form class="form-horizontal">
<div class="form-group">
<div class="col-sm-12">
<input type="email" class="form-control" id="email" placeholder="Enter email">
</div>
</div>
<br>
<br>
<br>
<div class="form-group">
<div class="col-sm-12">
<input type="password" class="form-control" id="pwd" placeholder="Enter password">
</div>
</div>
<br>
<br>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" class="btn btn-default btn-block">Submit</button>
</div>
</div>
</form>
<br>
<hr>
<br>
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-8">
<button type="button" class="btn btn-default btn-block" onclick="Loginpage.showHideContent(1)">Sign up</button>
</div>
<div class="col-sm-2">
</div>
</div>
</div>
<div id="signup-div">
<h3 align="center">Sign Up to see more</h3>
<form class="form-horizontal">
<div class="form-group">
<div class="col-sm-12">
<input type="email" class="form-control" id="email" placeholder="Enter email">
</div>
</div>
<br>
<br>
<br>
<div class="form-group">
<div class="col-sm-12">
<input type="password" class="form-control" id="pwd" placeholder="Enter password">
</div>
</div>
<br>
<br>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" class="btn btn-default btn-block">Submit</button>
</div>
</div>
</form>
<br>
<br>
<hr>
<button type="button" class="btn btn-default btn-block">Login With Facebook</button>
<hr>
<div class="row">
<div class="col-sm-4">
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-default btn-block" onclick="Loginpage.showHideContent(2)">Log in</button>
</div>
<div class="col-sm-4">
</div>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/js/bootstrap-dialog.min.js"></script>
I cannot push all elements to the bottom
<div class="row">
<div class="col-sm-4">
<%=p.select :accounts_receivables_items_type_id, options_from_collection_for_select(AccountsReceivablesItemsType.all, :id, :title, p.object.accounts_receivables_items_type_id), {}, class: "form-control chosen-select"%>
</div>
<div class="col-sm-2">
<%=p.input_field :total_less_tax, class: "form-control input-sm mb15", placeholder: "Netto"%>
</div>
<div class="col-sm-3">
<button type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Rimuovi voce</button>
</div>
</div>
GENERATED
<div class="form-group">
<label class="string optional control-label col-sm-3 control-label" for="accounts_receivable_accounts_receivables_items">Voci fattura</label>
<div class="col-sm-9">
<div id="invoice_products">
<div class="fields">
<div class="row">
<div class="col-sm-4">
<select class="form-control " id="accounts_receivable_accounts_receivables_items_attributes_1397853396301_accounts_receivables_items_type_id" name="accounts_receivable[accounts_receivables_items_attributes][1397853396301][accounts_receivables_items_type_id]"><option value="126">Vendita Auto Usata</option>
<option value="127">Pubblicità</option>
<option value="128">Contratto Gestione</option>
<option value="129">Corsa esente IVA</option>
<option value="130">Corsa con IVA</option></select>
</div>
<div class="col-sm-2">
<input class="numeric decimal required form-control" id="accounts_receivable_accounts_receivables_items_attributes_1397853396301_total_less_tax" min="0" name="accounts_receivable[accounts_receivables_items_attributes][1397853396301][total_less_tax]" placeholder="Netto" step="any" type="number" value="0.0">
</div>
<div class="col-sm-3">
<input id="accounts_receivable_accounts_receivables_items_attributes_1397853396301__destroy" name="accounts_receivable[accounts_receivables_items_attributes][1397853396301][_destroy]" type="hidden" value="false"><a class="remove_nested_fields" data-association="accounts_receivables_items" href="javascript:void(0)">
<button type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Rimuovi voce</button>
</a> </div>
</div>
</div></div>
<a class="add_nested_fields" data-association="accounts_receivables_items" data-blueprint-id="accounts_receivables_items_fields_blueprint" data-target="#invoice_products" href="javascript:void(0)">
<button type="button" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> Aggiungi un altra voce</button>
</a>
</div>
</div>
In case of the floated elements you can use display: flex though would this break any bootstrap grid stuff?
http://fiddle.jshell.net/TNyUa/3/show/
.col-sm-9, .form-group {
display: flex;
}
.form-group > label, .col-sm-9 > div {
align-self: flex-end;
}