This is probably very simple but I've been unable to figure it out. All I want to do is place the button underneath the input rows.
This is what I have attempted so far:
#subscribe button {
border: 0;
margin-top: 10px;
margin-left: 10px;
padding: 9px 27px;
cursor: pointer;
background: #f82249;
color: #fff;
transition: all 0.3s ease;
outline: none;
font-size: 14px;
border-radius: 50px;
position: relative;
}
<form method="POST" action="#">
<div class="form-row justify-content-center">
<div class="col-auto">
<input type="text" class="form-control" placeholder="Enter your email">
</div>
<div class="col-auto">
<input type="text" class="form-control" placeholder="A website I want to use Cobble on is:">
</div>
<div class="col-auto">
<button type="submit">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
and this is what the end result always is:
Any help would be immensely appreciated. Thank you.
You have all three form elements inside this div:
<div class="form-row justify-content-center">
Make another div just like that one and move the button inside it. In fact, it looks like you want each of those elements in its own "form-row" div. The only reason the two text inputs are on different lines is because they take up the whole row and they're wrapping.
Related
Here is the page in action, as you can see, my inputs fade nicely using jquery but no matter what I try I can't seem to get white div to shrink in a smooth manner as apposed to snapping: https://gyazo.com/983cc12230530459ea7c19c5484c53db
Code below:
.logo-margins {
margin: auto!important;
margin-bottom: 20px!important;
display: block!important;
padding-left: 28px;
}
.copyright-text {
font-size: 12px;
}
.step-one-object {
display: block;
}
.step-two-object {
display: none;
}
.center-box {
background: #fbfbfb;
transition: 2s;
padding: 20px;
border-radius: 15px;
}
.center-box2 {
height: 302px!important;
}
<body style="background-color: #0155a4">
<div class="container">
<div class="col-md-12">
<img class="logo-margins" style="width:500px" src=“">
</div>
<div class="col-md-12">
<form class="form-signin" autocomplete="off">
<div class="center-box">
<div class="text-center mb-4 step-one-object">
<p><br />Welcome to the Survey Centre. <br /><br /> To get started, enter the 'Company ID'
issued to you by your local representative, You can also find this ID on the front page of any report created for you by representative</p>
</div>
<div class="form-label-group">
<input type="text" id="inputCompanyId" class="form-control" placeholder="Email address" required autofocus>
<label for="inputCompanyId">Company ID</label>
</div>
<div class="form-label-group step-two-object" id="passwordField">
<input type="password" id="inputPassword" class="form-control" placeholder="Password">
<label for="inputPassword">Password</label>
</div>
<button class="btn btn-lg btn-primary btn-block step-one-object" onclick="advanceStep(event)">Continue</button>
<button class="btn btn-lg btn-primary btn-block step-two-object">Sign In</button>
<p class="mt-5 mb-3 text-muted text-center copyright-text">© Copyright 2018, Intellectual Property </p>
</div>
</form>
</div>
</div>
<script>
function advanceStep(event) {
event.preventDefault();
$(".step-one-object").fadeOut(300);
$(".step-two-object").delay(305).fadeIn(300);
}
</script>
</body>
The aim is to get the white box to shrink smoothly on click of the button while the elements inside also do their animations, ideally finishing at the same time, CSS transitions on the white div seem not to work (I think this is because the CSS on the box isn't actually changing, it's just reacting to the contents changing).
Thanks in advance,
Jake Wilcox
The transition CSS property takes more than just a duration.
If you want center-box to shrink while using transition, you need to choose a property on which it will be applied.
So what you want is to use it like this :
transition: height 2s;
And you also need to change the height property of center-box to 0 when the user clicks on the 'Continue' button.
I have a header-div on my Site. Inside the header I want to have a login-form in-line on the right side.
css:
#header {
position: absolute;
top: 0;
width: 100%;
height: 45px;
padding: 5;
background: #fff;
border-bottom: 1pt solid #ccc;
text-align: right;
font-weight: bold;
}
#header div {
/*display: inline-block;*/
cursor: pointer;
/*padding: 4px;*/
float: right;
text-decoration: none;
font-size: 15px;
margin-right: 5px;
}
#submitButton {
float:right;
}
html:
<div id="header">
<div id="login">
<form class="form-inline" role="form">
<div class="row">
<button type="submit" class="btn btn-default" id="submitButton">Login</button>
<div class="form-group col-sm-3">
<div class="input-group"> <span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span>
<input type="email" class="form-control" placeholder="Enter email" />
</div>
</div>
<div class="form-group col-sm-3">
<div class="input-group"> <span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
<input type="password" class="form-control" placeholder="password" />
</div>
</div>
</div>
</form>
</div>
</div>
That's what I have so far:
http://jsfiddle.net/n5qmc/254/
But if I go in the password form and press TAB I don't get in the email input field. Because of the float:right thing. I need to do this somehow different.
What is the right way to do this? Thanks!
What you need is tabindex but as your html is not good and in bootstrap you have used your own style so tabindex got different behaviour.
I have updated your fiddle with changes in html and css. Please check and let me know if its ok for you..
I have removed float and also removed extra margin which were causing problem now if you will use tab then it will go one by one and also will work better in resizing. I have also changed html so email field will be first in both case.
I'm having trouble getting a form to display properly. The following two lines are displaying horizontally, but they overlap each other where name ends and email begins. There's no CSS currently implemented on them, I've tried padding-left, margin-left, and a few other tricks but can't get them to separate. Any ideas?
<div id="contact" class="col-xs-6 col-md-6 col-lg-6">
<div class="center hero-unit">
<form action="success.html" method="GET">
<h4> Contact Me </h4>
<div class="form-group">
<div class="col-sm-4 col-md-4 col-lg-4">
<input type="text" placeholder="Name" size="20" id="inline">
</div>
<div class="col-sm-4 col-md-4 col-lg-4">
<input type="text" placeholder="Email Address" size="35" id="inline">
</div>
</div>
</form>
</div>
</div>
Including CSS for the hero-unit just in case that's causing issues
.hero-unit {
text-align: center;
background-color: #9C9C9C;
font-size: 11px;
margin: 30px;
padding: 30px;
line-height: 1.4em;
border-color: #C1C1C1;
color: white;
}
Just add to the style:
.hero-input {
padding:5px;
margin: 10px;
display:inline-block;
}
and to the inputs:
class="hero-input"
to have the margin and padding take effect on each input. Obviously you can modify it to your own liking of padding and margins. Basically the margins should either be in the input or the divs containing the inputs. Also you should avoid using duplicate ids. id="inline" should probably be class="inline" and if you use the extra hero-input class, then it could be class="inline hero-input"
I am using bootstrap by default textbox taking full width of column and I want to put search icon at the end to textbox.
My code is like this:
<div class="container">
<div class="row">
<div class="form-group col-lg-4">
<label class="control-label">Name</label>
<input id="txtName" class="form-control input-sm" />
<span class="glyphicon glyphicon-search"></span>
</div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
</div>
</div>
I don't want to use input group.
Please suggest an alternate way or alternate html with css.
Here are three different ways to do it:
Here's a working Demo in Fiddle Of All Three
Validation:
You can use native bootstrap validation states (No Custom CSS!):
<div class="form-group has-feedback">
<label class="control-label" for="inputSuccess2">Name</label>
<input type="text" class="form-control" id="inputSuccess2"/>
<span class="glyphicon glyphicon-search form-control-feedback"></span>
</div>
For a full discussion, see my answer to Add a Bootstrap Glyphicon to Input Box
Input Group:
You can use the .input-group class like this:
<div class="input-group">
<input type="text" class="form-control"/>
<span class="input-group-addon">
<i class="fa fa-search"></i>
</span>
</div>
For a full discussion, see my answer to adding Twitter Bootstrap icon to Input box
Unstyled Input Group:
You can still use .input-group for positioning but just override the default styling to make the two elements appear separate.
Use a normal input group but add the class input-group-unstyled:
<div class="input-group input-group-unstyled">
<input type="text" class="form-control" />
<span class="input-group-addon">
<i class="fa fa-search"></i>
</span>
</div>
Then change the styling with the following css:
.input-group.input-group-unstyled input.form-control {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.input-group-unstyled .input-group-addon {
border-radius: 4px;
border: 0px;
background-color: transparent;
}
Also, these solutions work for any input size
Adding a class with a width of 90% to your input element and adding the following input-icon class to your span would achieve what you want I think.
.input { width: 90%; }
.input-icon {
display: inline-block;
height: 22px;
width: 22px;
line-height: 22px;
text-align: center;
color: #000;
font-size: 12px;
font-weight: bold;
margin-left: 4px;
}
EDIT
Per dan's suggestion, it would not be wise to use .input as the class name, some more specific would be advised. I was simply using .input as a generic placeholder for your css
<input type="text" name="whatever" id="funkystyling" />
Here's the CSS for the image on the left:
#funkystyling {
background: white url(/path/to/icon.png) left no-repeat;
padding-left: 17px;
}
And here's the CSS for the image on the right:
#funkystyling {
background: white url(/path/to/icon.png) right no-repeat;
padding-right: 17px;
}
I liked #KyleMit's answer on how to make an unstyled input group, but in my case, I only wanted the right side unstyled - I still wanted to use an input-group-addon on the left side and have it look like normal bootstrap. So, I did this:
css
.input-group.input-group-unstyled-right input.form-control {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.input-group-unstyled-right .input-group-addon.input-group-addon-unstyled {
border-radius: 4px;
border: 0px;
background-color: transparent;
}
html
<div class="input-group input-group-unstyled-right">
<span class="input-group-addon">
<i class="fa fa-envelope-o"></i>
</span>
<input type="text" class="form-control">
<span class="input-group-addon input-group-addon-unstyled">
<i class="fa fa-check"></i>
</span>
</div>
You can do it in pure CSS using the :after pseudo-element and getting creative with the margins.
Here's an example, using Font Awesome for the search icon:
.search-box-container input {
padding: 5px 20px 5px 5px;
}
.search-box-container:after {
content: "\f002";
font-family: FontAwesome;
margin-left: -25px;
margin-right: 25px;
}
<!-- font awesome -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="search-box-container">
<input type="text" placeholder="Search..." />
</div>
I'm trying to create a responsive form, where some things wrap, and others do not.
I would like the form to look like this on desktop
and like this on mobile
Notice that the icon stays to the right. Unfortunately I cannot use a background image for the icon, as I need to show a tooltip on hover of the icon.
When I attempt this, however, the icon wraps:
So, how can I make the icon be its own element (span or div), yet not wrap below the text field?
Here is one attempt: http://jsfiddle.net/XVu6V/
And here is a Bootstrap 3 attempt: http://jsfiddle.net/syhLJ/1/ I'd really like to use Bootstrap.
Here's some HTML:
<div text-element class="form-group row">
<label for="firstName" class="col-md-2 control-label">First Name</label>
<div class="col-md-5">
<input type="text" class="form-control" id="firstName" />
</div>
<div class="col-md-1 validation-icon required"></div>
<div class="col-md-3 validation-message">
Needed for communication.
</div>
</div>
Why not wrap the icon and <input> inside a div, set that div to position:relative and add a padding-right the same width of the icon. Then set the <input> 100% wide and the icon position:absolute;top:0;right:0? That'll force the icon to always sit to the right of the <input>.
Something like http://jsfiddle.net/syhLJ/7/.
You can view just the HTML preview of it at http://fiddle.jshell.net/syhLJ/7/show/, I use this solution quite a bit and it's never failed so far.
You can stack col-xx-xx together without overriding bootstrap's default styles.
http://jsfiddle.net/99SFW/2/
<div class="container">
<form class="form-horizontal" role="form">
<div text-element class="form-group row">
<label for="firstName" class="col-md-2 col-sm-2 col-xs-12 control-label">First Name</label>
<div class="col-md-5 col-sm-5 col-xs-9">
<input type="text" class="form-control" id="firstName" />
</div>
<div class="col-md-1 col-sm-1 col-xs-1 validation-icon required"></div>
<div class="col-md-3 col-sm-12 col-xs-12 validation-message">Needed for communication.</div>
</div>
</form>
</div>
Not really optimal but you could try absolutely positioning the input and floating it to the left when on a smaller screen, while floating the icon to the right. Then I guess make the input a percentage that will give you some spacing between it and the icon.
.form-group .form-control {
position: absolute;
float: left;
}
I've updated your fiddle here
The HTML goes something like this...
<form>
<div>
<label for="firstName" class="label">First Name</label>
<div class="input">
<input type="text" class="form-control" id="firstName" />
</div>
<div class="icon">R</div>
<div class="validation">Needed for communication.</div>
</div>
</form>
And the css
.input {
float: left;
width:calc(100% - 35px);
max-width: 500px;
}
.icon {
float: left;
background-color: orange;
width: 32px;
height: 32px;
display: block;
margin: 0 4px;
text-align: center;
vertical-align: middle;
line-height: 30px;
color: white;
font-weight: bold;
}
.validation {
float: left;
}
Or you could float the button right and drag it up with a negative margin.
.form-group .validation-icon {
float: right;
margin-top: -33px;
}
#media (min-width: 992px) {
.form-group .validation-icon {
float: left;
margin-top: 0;
}
}
.form-control {
width: 90%;
}
http://jsfiddle.net/Anp7s/2/