Adding Currency Value in Css puts it onto seperate line - html

I've added the following to the css and html file:
.currencyinput {
border: 1px inset #eee;
}
.currencyinput input {
border: 0;
}
<td><span class="currencyinput">$<input type="text" name="amount"></span></td>
And my resulting page shows the $ and then the textbox on a new line below it. I was intending the $ to be in the textbox.
Appreciate any insight on this. Thanks!

Consider simulating an input field with a fixed using a span with a border around a border less input field. Here's a basic example:
<div class="container">
<h3>Basic form example</h3>
<div class="form-group">
<div class="input-icon">
<i>$</i>
<input type="text" class="form-control" placeholder="0.00">
</div>
</div>
<div class="form-group">
<div class="input-icon input-icon-right">
<i>€</i>
<input type="text" class="form-control" placeholder="0.00">
</div>
</div>
<div class="form-group">
<div class="input-icon">
<i class="fa fa-bitcoin"></i>
<input type="text" class="form-control" placeholder="0.00">
</div>
</div>
<h3>Example using <code>form-inline</code></h3>
<div class="alert alert-danger visible-xs">This window needs to be made
larger to see the inline example.</div>
<form class="form-inline">
Some text here
<div class="form-group input-icon">
<i>$</i>
<input type="text" class="form-control" placeholder="0.00">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
CSS:
.input-icon {
position: relative;
}
.input-icon > i {
position: absolute;
display: block;
transform: translate(0, -50%);
top: 50%;
pointer-events: none;
width: 25px;
text-align: center;
font-style: normal;
}
.input-icon > input {
padding-left: 25px;
padding-right: 0;
}
.input-icon-right > i {
right: 0;
}
.input-icon-right > input {
padding-left: 0;
padding-right: 25px;
text-align: right;
}

use this css for remove focus border input:focus{outline: none;}
.currencyinput span{
position: relative;
}
.currencyinput input{
padding-left:20px;
}
.currencyinput span{
left:15px;
top:0
position: absolute;
}
.currencyinput input:focus {
outline: none;
}
<span class="currencyinput"><span>$</span><input type="text" name="amount"></span>

Related

Clickable image inside input field - position not working

I know this question has been asked and aswered before, but for some reason, the answers are not working for me; so any help is much appreciated.
I'm creating a hybrid mobile app and I need to add an clickable icon (SVG) inside an input field. Even though I have managed to add the icon, when I test my design in different screens, the icon doesn't not respect the position I need it to be in.
Here are some shots: This is how it's supposed to look in all screens and this is what it looks like in landscape mode, for example.
Here's my code: https://codepen.io/paulamourad/pen/djXvxq
CSS:
.wallet-body {
width: 100%;
margin: 0 auto;
}
.form-group {
position: relative;
}
.form-group input {
border: 1px solid #2C2C2C;
height: 48px;
}
.qr-scanner-img {
float: left;
width: 11%;
margin-top: -39px;
margin-left: 120px;
position: relative;
}
HTML:
<div class="wallet-body">
<form class="form-pagar">
<div class="form-group">
<input type="amount" class="form-control" id="amount" placeholder="Monto">
</div>
<div class="form-group">
<input type="IDuser" class="form-control" id="IDuser" placeholder="Email del destinatario">
<a href="#">
<img class="qr-scanner-img" src="img/qr.svg" alt="qr"></a>
</a>
</div>
</form>
</div>
.wallet-body {
width: fit-content;
margin: 0 auto;
float: left;
}
.form-group{
position: relative;
}
.form-group input {
border: 1px solid #2C2C2C;
height: 48px;
}
.qr-scanner-img {
width: 11%;
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
}
<div class="wallet-body">
<form class="form-pagar">
<div class="form-group">
<input type="amount" class="form-control" id="amount" placeholder="Monto">
</div>
<div class="form-group">
<input type="IDuser" class="form-control" id="IDuser" placeholder="Email del destinatario">
<a href="#">
<img class="qr-scanner-img" src="img/qr.svg" alt="qr"></a>
</a>
</div>
</form>
</div>

message box to show in right column

I want to design the responsive contact form where the layout is name, email, subject fields be in one column and message field be in the another column. I could not make that message field appear in another column though I have used the width as 50%. Here is the demo
http://jsbin.com/vuxojuqeve/edit?html,css,output
The code
#responsive-form {
max-width: 600px;
margin: 0 auto;
width: 100%;
}
.form-row {
width: 100%;
}
.form-row input {
margin: 10px 0;
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
.button {
float: left;
background: #CA0002;
color: #fff;
text-transform: uppercase;
border: none;
padding: 8px 20px;
cursor: pointer;
}
input[type="text"],
textarea {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box
}
.half-size {
width: 50%;
}
<div id="responsive-form" class="clearfix">
<div class="half-size">
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
</div>
<div class="half-size">
<div class="form-row">
<div class="column">
<textarea class="form-control" cols="40" rows="10"></textarea>
</div>
</div>
</div>
<div class="form-row">
<div class="column">
<input type="submit" name="name" class="button">
</div>
</div>
</div>
</div>
This is what I wanted with submit button on the left column
You need to set your containers to display:inline-block, as they are block level elements by default and won't allow others to be positioned beside them.
I'm using 45% because 50% + 50% is not usually 100% when using inline-blocks because of an issue with whitespace, there are some ways around it, I'll let you decide for yourself which hack to use...
#responsive-form {
max-width: 600px;
margin: 0 auto;
width: 100%;
}
.form-row {
width: 100%;
}
.form-row input {
margin: 10px 0;
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
.button {
float: left;
background: #CA0002;
color: #fff;
text-transform: uppercase;
border: none;
padding: 8px 20px;
cursor: pointer;
}
input[type="text"],
textarea {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box
}
.half-size {
width: 45%;
display:inline-block;
}
<div id="responsive-form" class="clearfix">
<div class="half-size">
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
</div>
<div class="half-size">
<div class="form-row">
<div class="column">
<textarea class="form-control" cols="40" rows="10"></textarea>
</div>
</div>
</div>
<div class="form-row">
<div class="column">
<input type="submit" name="name" class="button">
</div>
</div>
</div>
</div>
If there are columns, use flexbox.
Inputs and textarea width unit is vw and e.g. min-width: 180px.
Example
body {
margin: 0;
}
::placeholder,
input[type="submit"] {
color: #BACEE7;
font-weight: bold;
}
.form {
display: flex;
justify-content: center;
padding: 15px;
}
.form input,
.form textarea {
min-width: 180px;
background: #F2F2F2;
border: 1px solid #ccc;
text-transform: uppercase;
border-radius: 3px;
text-align: center;
box-sizing: border-box;
}
.form>.inputs {
margin-right: 5px;
}
.form>.inputs>input {
width: 30vw;
display: block;
margin-bottom: 5px;
padding: 1.5vw;
}
.form>.inputs>input:last-child {
margin-bottom: 0 !important;
}
.form textarea {
width: 35vw;
padding-top: 80px;
display: block;
height: 100%;
}
.form input[type="submit"] {
background: #CA0002;
color: white;
border: none;
cursor: pointer;
}
<div class="form">
<div class="inputs">
<input type="text" name="first_name" placeholder="first name">
<input type="text" name="last_name" placeholder="last name">
<input type="email" name="email" placeholder="email">
<input type="text" name="organization" placeholder="organization">
<input type="tel" name="phone" placeholder="phone">
<input type="submit" name="submit">
</div>
<div class="textarea">
<textarea name="" id="" cols="30" placeholder="message"></textarea>
</div>
</div>

Elements position relative to text input

I have the following challenge. When an user is typing somehting in an input field, I want to show a reset button with a position center right of the input.
I am not able to change the html structure of the label, input, button and the error message. And I dont want to use browsers support. Does somebody has a creative idea how to do this? Thanks in advance.
label {
display: block;
}
.btn {
padding: 10px;
background-color: green;
color: #fff;
}
input {
padding: 10px;
}
<div class="shopping-cart-coupon">
<div class="form-group">
<label for="coupon">Coupon</label>
<input name="coupon" type="text" id="coupon">
<a id="" style="" class="btn" href=''>Activate</a>
<span style="display:block;color:red;">Error message</span>
<a class="reset">x</a>
</div>
</div>
Outline
Wrap anything that you want to stay as it is now with an <div style="display: inline-block;position:relative;">. This creates a positioning context in which you can position anything afterwards. Then position your reset button with position: absolute and the offsets you need, inside and relative to the wrapper you created.
Here's a try at it, but I'm uncertain that I understood your scenario.
label {
display: block;
}
.btn {
padding: 10px;
background-color: green;
color: #fff;
}
input {
padding: 10px;
}
.input-wrapper {
position: relative;
display: inline-block;
}
.reset {
position: absolute;
right: 3px;
top: 7px;
}
<div class="shopping-cart-coupon">
<div class="form-group">
<label for="coupon">Coupon</label>
<div class="input-wrapper">
<input name="coupon" type="text" id="coupon">
<a class="reset">x</a>
</div>
<a id="" style="" class="btn" href=''>Activate</a>
<span style="display:block;color:red;">Error message</span>
</div>
</div>
.form-group {
position: relative;
}
label {
display: block;
}
.btn {
padding: 10px;
background-color: green;
color: #fff;
}
input {
padding: 10px;
}
.reset {
margin-left: -20px;
margin-top: 10px;
position: absolute;
}
<div class="shopping-cart-coupon">
<div class="form-group">
<label for="coupon">Coupon</label>
<input name="coupon" type="text" id="coupon">
<a class="reset">x</a>
<a id="" style="" class="btn" href=''>Activate</a>
<span style="display:block;color:red;">Error message</span>
</div>
</div>

Bootstrap: Form display

I like bootstrap, but when it comes to forms it's really inconvenient. I made myself classes for a comment box that should flowing on the top and (ideally push other elements below on smartphone screens). I couldn't figure out how to have the name and surname on the same line. I've made following demo:
.comment-box-container {
position: absolute;
top: 812px;
right: 40px;
z-index: 1001;
width: 500px;
padding-top: 0px;
margin-top: 0px;
}
.comment-box {
background-color: white;
border: 1px solid #DCE0E0;
padding: 10px;
}
.comment-box-header {
background-color: rgba(38, 173, 228, 0.9);
color: white;
height: 40px;
padding: 5px;
padding-left: 10px;
font-size: 20px;
text-transform: capitalize;
font-weight: normal;
margin-right: 0px;
margin-left: 0px;
}
/* Remove rounded borders on input fields */
.form-control {
border-radius: 0;
}
/* Disable the ability to resize textareas */
textarea {
resize: none;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="comment-box-container">
<div class="comment-box-header">
Kontakt
</div>
<div class="comment-box">
<form role="form" class="forminline">
<div class="form-group">
<input type="surname" class="form-control" placeholder="Vorname" id="surname">
</div>
<div class="form-group">
<input type="name" class="form-control" placeholder="Name" id="name">
</div>
<div class="form-group">
<input type="telephone" class="form-control" placeholder="Telefon" id="telephone">
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Email" id="email">
</div>
<div class="form-group">
<textarea class="form-control" id="comments" name="comments" placeholder="Nachricht" rows="5"></textarea>
</div>
<div class="form-group">
<button class="btn" type="submit">Interesse bekunden</button>
</div>
</form>
</div>
</div>
I'd like to display surname and name on the same line and the button in the center over the whole width. Possible? (P.S. What kind of buttons is Stack Overflow using below?)
JSfiddle demo
You need to add grid classes to the first two inputs. col-xs-6
will divide the inputs by giving them a width of 50% and align
them in a line. Make sure you have wrapped the two inputs inside a
row so that next inputs are aligned as it is, without disturbing
the flow.
text-center class to the commentbox class will align the button
to center.
To reduce the space between the two input box, you will need to override the padding-left to 0. Note that I am targeting the second input so that only the spacing is effected.
.comment-box .form-group.col-xs-6:nth-child(2) {
padding-left: 0;
}
To give a custom color to the button, you will again need to override the bootstrap classes.
.comment-box .btn {
background-color: lightgray;
}
.comment-box-container {
position: absolute;
top: 10px;
right: 40px;
z-index: 1001;
width: 500px;
padding-top: 0px;
margin-top: 0px;
}
.comment-box {
background-color: white;
border: 1px solid #DCE0E0;
padding: 10px;
}
.comment-box-header {
background-color: rgba(38, 173, 228, 0.9);
color: white;
height: 40px;
padding: 5px;
padding-left: 10px;
font-size: 20px;
text-transform: capitalize;
font-weight: normal;
margin-right: 0px;
margin-left: 0px;
}
/* Remove rounded borders on input fields */
.form-control {
border-radius: 0;
}
/* Disable the ability to resize textareas */
textarea {
resize: none;
}
.comment-box .form-group.col-xs-6:nth-child(2) {
padding-left: 0;
}
.comment-box .btn {
background-color: lightgray;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="comment-box-container">
<div class="comment-box-header">
Kontakt
</div>
<div class="comment-box text-center">
<form role="form" class="forminline">
<div class="row">
<div class="form-group col-xs-6">
<input type="surname" class="form-control" placeholder="Vorname" id="surname">
</div>
<div class="form-group col-xs-6">
<input type="name" class="form-control" placeholder="Name" id="name">
</div>
</div>
<div class="form-group">
<input type="telephone" class="form-control" placeholder="Telefon" id="telephone">
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Email" id="email">
</div>
<div class="form-group">
<textarea class="form-control" id="comments" name="comments" placeholder="Nachricht" rows="5"></textarea>
</div>
<div class="form-group">
<button class="btn" type="submit">Interesse bekunden</button>
</div>
</form>
</div>
</div>

How to put my form on top of an image in css/html?

Good day developers! I would like to ask if how can I make my form appear on top of my image? The problem is that my form appear at the bottom. Here's the image of my screenshot.
Here are my codes:
HTML
<body>
<div class="container" align="center">
<div id="image">
<img src="assets/img/imac.png" style="width:640px; height:678">
</div>
<div id="loginForm">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Please sign in</h3>
</div>
<div class="panel-body">
<form accept-charset="UTF-8" role="form">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="E-mail" name="email" type="text">
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" name="password" type="password" value="">
</div>
<div class="checkbox">
<label>
<input name="remember" type="checkbox" value="Remember Me"> Remember Me
</label>
</div>
<input class="btn btn-lg btn-success btn-block" type="submit" value="Login">
</fieldset>
</form>
</div>
</div>
</div>
</div>
CSS
body {
background-color: #2ecc71;
}
.container {
width: 1000px;
height: 700px;
margin-top: 100px;
}
#loginForm{
width: 500px;
height: 400px;
}
Make the #image be position:absolute and fill the .container (which is made position:relative) with it.
body {
background-color: #2ecc71;
}
.container {
width: 1000px;
height: 700px;
margin-top: 100px;
position:relative;
}
#loginForm {
width: 500px;
height: 400px;
position:relative;
z-index:10;
}
#image{
top:0;
left:0;
right:0;
bottom:0;
position:absolute;
}
<div class="container" align="center">
<div id="image">
<img src="http://dummyimage.com/600x678/cccccc/ffffff.jpg&text=monitor+image" style="width:640px; height:678">
</div>
<div id="loginForm">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Please sign in</h3>
</div>
<div class="panel-body">
<form accept-charset="UTF-8" role="form">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="E-mail" name="email" type="text">
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" name="password" type="password" value="">
</div>
<div class="checkbox">
<label>
<input name="remember" type="checkbox" value="Remember Me">Remember Me
</label>
</div>
<input class="btn btn-lg btn-success btn-block" type="submit" value="Login">
</fieldset>
</form>
</div>
</div>
</div>
</div>
Create a div the size of the image, and make the image the background image for the div.
Then place a div container inside this div for the form itself. You can then use CSS to position the form div using margins.
<div id="image-container">
<div id="form-container">
// your form
</div>
</div>
#image-container {
width: 500px;
height: 500px;
background: url(/* your image */);
}
#form-container {
width:350px;
margin: 30px auto 0 auto;
}
Obviously, you need to replace the sizes with ones of your actual image, and the margin values to make your form content fit within the screen of the computer in your image.
That should work, I'm coding this on my phone so apologies if I miss something trivial!
I used the last example and made it simpler. Just adjust for image size and use padding to position the form.
<div style="width:529px; height:220px; background-image:url('image.jpg')" align="center">
<div style="width:529px; padding: 165 0 0 0" align="center">
...form ...
<div>
<div>
Try this
* {
box-sizing: border-box;
font-family: sans-serif;
}
.form-container {
display: flex;
justify-content: center;
background: url("https://parrot-tutorial.com/images/mask-smog.jpg") no-repeat center;
background-size: cover;
position: relative;
min-height: 400px;
padding: 24px;
}
.my-form {
background-color: #fff;
padding: 16px;
}
.form-header {
text-align: center;
padding: 0;
margin-top: 0;
font-size: 2em;
}
.form-group {
margin-bottom: 1rem;
}
label {
display: inline-block;
margin-bottom: .5rem;
}
.form-control {
display: block;
width: 100%;
padding: .375rem .75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #f1f1f1;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: .25rem;
}
.form-text {
color: #6c757d;
display: block;
margin-top: .25rem;
font-size: 80%;
font-weight: 400;
}
.btn {
display: block;
width: 100%;
font-weight: 400;
color: #ffffff;
cursor: pointer;
text-align: center;
vertical-align: middle;
user-select: none;
border: 1px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
background-color: #007bff;
}
<div class="form-container">
<form action="/html/form-action.php" class="my-form" method="POST">
<h2 class="form-header">Login</h2>
<div class="form-group">
<label for="exampleEmail">Email address</label>
<input type="email" class="form-control" id="exampleEmail" placeholder="Enter email" name="uemail">
<small class="form-text">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="examplePassword">Password</label>
<input type="password" class="form-control" id="examplePassword" placeholder="Password" name="pwd">
</div>
<div class="form-group">
<input type="checkbox" id="exampleCheck" name="saveinfo">
<label for="exampleCheck">Remember me</label>
</div>
<button type="submit" class="btn">Submit</button>
</form>
</div>
Reference:Add a Form on Image