I have a registration form where the there is icons in the form input. When i resize the window it displaces (squeezes) which is very annoying can anyone tell me what should i do to make it fixes in the place where it is.
#username-logo {
position: relative;
float: left;
top: 40px;
left: 15%;
}
#password-logo {
position: relative;
float: left;
top: 40px;
left: 15%;
}
#email-logo {
position: relative;
float: left;
top: 40px;
left: 15%;
}
<form id="form-container">
<h1 id="linklist">Register</h1>
<input type="text" name="username" id="username" placeholder="Username" required="required">
<i class="fas fa-user" id="username-logo"></i>
<input type="password" name="password" id="password" placeholder="Password" required="required">
<i class="fas fa-lock" id="password-logo"></i>
<input type="email" name="email" id="email" placeholder="Email" required="required">
<i class="fas fa-envelope" id="email-logo"></i>
<input type="submit" name="submit" id="submit" value="Register">
</form>
Wrap the icon and input and from there you can style it easier. The placement of the icon all depends on the design you have.
.register-form {
display: flex;
flex-wrap: wrap;
max-width: 20rem;
}
.input-container {
display: flex;
}
.input-container input {}
.input-container i {}
<h1 id="linklist">Register</h1>
<form id="form-container" class="register-form">
<div class="input-container">
<input type="text" name="username" id="username" placeholder="Username" required="required">
<i class="fas fa-user" id="username-logo"></i>
</div>
<div class="input-container">
<input type="password" name="password" id="password" placeholder="Password" required="required">
<i class="fas fa-lock" id="password-logo"></i>
</div>
<div class="input-container">
<input type="email" name="email" id="email" placeholder="Email" required="required">
<i class="fas fa-envelope" id="email-logo"></i>
</div>
<button type="submit" class="button">Register</button>
</form>
Put your container position: relative and logo position: absolute and reposition using left/right/top/bottom .
This way the logo's will be positioned according to container (here input) not according to body and will not displaces on resize if used correctly
Related
I am gathering customer data from a web app - however once data is input the data displays in the URL search bar and I am just wondering about how to prevent that from happening?
here is my current code:
<form>
<div class="row">
<div class="col-75">
<div class="container">
<form action="/action_page.php", method="POST">
<div class="row">
<div class="col-50">
<h3>Billing Address</h3>
<label for="fname"><i class="fa fa-user"></i> Full Name</label>
<input type="text" id="fname" name="firstname" placeholder="John M. Doe">
<label for="email"><i class="fa fa-envelope"></i> Email</label>
<input type="text" id="email" name="email" placeholder="john#example.com">
<label for="adr"><i class="fa fa-address-card-o"></i> Address</label>
<input type="text" id="adr" name="address" placeholder="1234 Example Street, Richmond">
<label for="city"><i class="fa fa-institution"></i> Suburb</label>
<input type="text" id="city" name="city" placeholder="Melbourne">
<div class="row">
<div class="col-50">
<label for="state">State</label>
<input type="text" id="state" name="state" placeholder="Victoria">
</div>
<div class="col-50">
<label for="postcode">Post Code</label>
<input type="text" id="postcode" name="postcode" placeholder="3934">
</div>
</div>
</div>
<div class="col-50">
<h3>Payment</h3>
<label for="fname">Accepted Cards</label>
<div class="icon-container">
<i class="fa fa-cc-visa" style="color:navy;">Visa</i>
<i class="fa fa-cc-amex" style="color:blue;">Amex</i>
<i class="fa fa-cc-mastercard" style="color:red;">Mastercard</i>
</div>
<label for="cname">Name on Card</label>
<input type="text" id="cname" name="cardname" placeholder="John More Doe">
<label for="ccnum">Credit card number</label>
<input type="text" id="ccnum" name="cardnumber" placeholder="1111-2222-3333-4444">
<label for="expmonth">Exp Month</label>
<input type="text" id="expmonth" name="expmonth" placeholder="September">
<div class="row">
<div class="col-50">
<label for="expyear">Exp Year</label>
<input type="text" id="expyear" name="expyear" placeholder="2018">
</div>
<div class="col-50">
<label for="cvv">CVV</label>
<input type="text" id="cvv" name="cvv" placeholder="352">
</div>
</div>
</div>
</div>
<label>
<input type="checkbox" checked="checked" name="sameadr"> Shipping address same as billing
</label>
<input type="submit" value="Continue to checkout" class="btn">
</form>
</div>
</div>
.row {
display: -ms-flexbox; /* IE10 */
display: flex;
-ms-flex-wrap: wrap; /* IE10 */
flex-wrap: wrap;
margin: 0 -16px;
}
.col-25 {
-ms-flex: 25%; /* IE10 */
flex: 25%;
}
.col-50 {
-ms-flex: 50%; /* IE10 */
flex: 50%;
}
.col-75 {
-ms-flex: 75%; /* IE10 */
flex: 75%;
}
.col-25,
.col-50,
.col-75 {
padding: 0 16px;
}
.container {
background-color: #f2f2f2;
padding: 5px 20px 15px 20px;
border: 1px solid lightgrey;
border-radius: 3px;
}
input[type=text] {
width: 100%;
margin-bottom: 20px;
padding: 12px;
border: 1px solid #ccc;
border-radius: 3px;
}
label {
margin-bottom: 10px;
display: block;
}
.icon-container {
margin-bottom: 20px;
padding: 7px 0;
font-size: 24px;
}
.btn {
background-color: #04AA6D;
color: white;
padding: 12px;
margin: 10px 0;
border: none;
width: 100%;
border-radius: 3px;
cursor: pointer;
font-size: 17px;
}
.btn:hover {
background-color: #45a049;
}
span.price {
float: right;
color: grey;
}
/* Responsive layout - when the screen is less than 800px wide, make the two columns stack on top of each other instead of next to each other (and change the direction - make the "cart" column go on top) */
#media (max-width: 800px) {
.row {
flex-direction: column-reverse;
}
.col-25 {
margin-bottom: 20px;
}
}
Any help would be really appreciated :)
You have an unnecessary <form> tag on the first line of your HTML and you are missing a closing </div> tag at the end. Changing this seems to resolve the issue:
<div class="row">
<div class="col-75">
<div class="container">
<form action="/action_page.php" , method="POST">
<div class="row">
<div class="col-50">
<h3>Billing Address</h3>
<label for="fname"><i class="fa fa-user"></i> Full Name</label>
<input type="text" id="fname" name="firstname" placeholder="John M. Doe">
<label for="email"><i class="fa fa-envelope"></i> Email</label>
<input type="text" id="email" name="email" placeholder="john#example.com">
<label for="adr"><i class="fa fa-address-card-o"></i> Address</label>
<input type="text" id="adr" name="address" placeholder="1234 Example Street, Richmond">
<label for="city"><i class="fa fa-institution"></i> Suburb</label>
<input type="text" id="city" name="city" placeholder="Melbourne">
<div class="row">
<div class="col-50">
<label for="state">State</label>
<input type="text" id="state" name="state" placeholder="Victoria">
</div>
<div class="col-50">
<label for="postcode">Post Code</label>
<input type="text" id="postcode" name="postcode" placeholder="3934">
</div>
</div>
</div>
<div class="col-50">
<h3>Payment</h3>
<label for="fname">Accepted Cards</label>
<div class="icon-container">
<i class="fa fa-cc-visa" style="color:navy;">Visa</i>
<i class="fa fa-cc-amex" style="color:blue;">Amex</i>
<i class="fa fa-cc-mastercard" style="color:red;">Mastercard</i>
</div>
<label for="cname">Name on Card</label>
<input type="text" id="cname" name="cardname" placeholder="John More Doe">
<label for="ccnum">Credit card number</label>
<input type="text" id="ccnum" name="cardnumber" placeholder="1111-2222-3333-4444">
<label for="expmonth">Exp Month</label>
<input type="text" id="expmonth" name="expmonth" placeholder="September">
<div class="row">
<div class="col-50">
<label for="expyear">Exp Year</label>
<input type="text" id="expyear" name="expyear" placeholder="2018">
</div>
<div class="col-50">
<label for="cvv">CVV</label>
<input type="text" id="cvv" name="cvv" placeholder="352">
</div>
</div>
</div>
</div>
<label>
<input type="checkbox" checked="checked" name="sameadr"> Shipping address same as billing
</label>
<input type="submit" value="Continue to checkout" class="btn">
</form>
</div>
</div>
</div>
(Note: my editor may have formatted your code differently to the original question)
I have this code below which is a simple html form. What i'm trying to do is make all of the inputs have max widths inside the form-panel and look something like the image below.
I tried setting max-width for all the inputs inside the panel but it doesn't seem to be working. Any help would be greatly appreciated.
input[type="text"],
input[type="email"],
input[type="password"] {
padding: 4px 20px;
height: 35px;
border: 1px solid black;
margin: 10px;
border-radius: 3px;
max-width: 100%;
}
.form-panel {
display: table;
background-color: #b7bcbe;
}
<body>
<div class="form-panel">
<div class="form-name">
<input type="text" name="fname" placeholder="First Name">
<input type="text" name="lname" placeholder="Last Name">
<br>
</div>
<div class="form-email">
<input type="email" name="email" placeholder="Email Address">
<br>
</div>
<div class="form-password">
<input type="password" name="password" placeholder="Password">
<input type="password" name="cpassword" placeholder="Comfirm Password">
</div>
</div>
<input type="submit" class="btn btn-default submit-button" value="Sign up!">
</body>
You can use flex-box instead of table.
As you use display: table - the column will have the same width (there is no colspan option)
Use display: flex for each columns and set flex-grow: 1 so that all elements will grow up and fill the parent.
input[type="text"],
input[type="email"],
input[type="password"] {
padding: 4px 20px;
height: 35px;
border: 1px solid black;
margin: 10px;
border-radius: 3px;
flex-grow: 1;
}
.form-row {
flex-direction: row;
display: flex;
}
.form-panel {
background-color: #b7bcbe;
}
<body>
<div class="form-panel">
<div class="form-row form-name">
<input type="text" name="fname" placeholder="First Name">
<input type="text" name="lname" placeholder="Last Name">
<br>
</div>
<div class="form-row form-email">
<input type="email" name="email" placeholder="Email Address">
<br>
</div>
<div class="form-row form-password">
<input type="password" name="password" placeholder="Password">
<input type="password" name="cpassword" placeholder="Comfirm Password">
</div>
</div>
<input type="submit" class="btn btn-default submit-button" value="Sign up!">
</body>
You have written common css for all input elements..write separate css for that particular input field and put important.
input[type="text"],
input[type="email"],
input[type="password"] {
padding: 4px 20px;
height: 35px;
border: 1px solid black;
margin: 10px;
border-radius: 3px;
max-width: 100%;
}
.form-panel {
display: table;
background-color: #b7bcbe;
}
<body>
<div class="form-panel">
<div class="form-name">
<input type="text" name="fname" placeholder="First Name">
<input type="text" name="lname" placeholder="Last Name">
<br>
</div>
<div class="form-email">
<input type="email" name="email" style="width: 100%;max-width: 86%;" placeholder="Email Address">
<br>
</div>
<div class="form-password">
<input type="password" name="password" placeholder="Password">
<input type="password" name="cpassword" placeholder="Comfirm Password">
</div>
</div>
<input type="submit" class="btn btn-default submit-button" value="Sign up!">
</body>
just add this line:
.form-email input {width: calc(100% - 20px);}
^--------[margin-left + margin-right]
input[type="text"],
input[type="email"],
input[type="password"] {
padding: 4px 20px;
height: 35px;
border: 1px solid black;
margin: 10px;
border-radius: 3px;
max-width: 100%;
}
.form-panel {
display: table;
background-color: #b7bcbe;
}
.form-email input {width: calc(100% - 20px);}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="form-panel">
<div class="form-name">
<input type="text" name="fname" placeholder="First Name">
<input type="text" name="lname" placeholder="Last Name">
<br>
</div>
<div class="form-email">
<input type="email" name="email" placeholder="Email Address">
<br>
</div>
<div class="form-password">
<input type="password" name="password" placeholder="Password">
<input type="password" name="cpassword" placeholder="Comfirm Password">
</div>
</div>
<input type="submit" class="btn btn-default submit-button" value="Sign up!">
I have a page that includes a large vertical form and I need it to be resized depending on the screen size. I want the form inputs to shrink with adequate margins on both the left and right side. My css consists of code like:
.container-register input#search, select {
width: 300px;
}
This makes the initial input widths fairly long so I have tried using #media (max-width) scripts to change the length but it looks very hardcoded. I want it to seamlessly change depending on the viewport without me having to use these #media scripts for every possible viewport width. I was thinking maybe something like flex? However I was having trouble using it.
<div class="body-content-register">
<div class="wrapper">
<center><section id="bg" class="zoom-register">
<div class="box-register">
<center><h1>Register</h1></center>
<form class="register">
<div class="container-register">
<span class="icon"><i class="fa fa-user"></i></span>
<input type="search" name="fullname" id="search" placeholder="Full Name">
</div><br><br><br><br>
<div class="container-register">
<span class="icon"><i class="fa fa-envelope"></i></span>
<input type="search" id="search" placeholder="Email">
</div><br><br><br><br>
<div class="container-register">
<span class="icon"><i class="fa fa-user"></i></span>
<input type="search" id="search" placeholder="Username">
</div><br><br><br><br>
<div class="container-register">
<span class="icon"><i class="fa fa-birthday-cake"></i></span>
<input type="search" id="search" placeholder="Date of Birth">
</div><br><br><br><br>
<div class="container-register">
<span class="icon"><i class="fa fa-map-marker"></i></span>
<input type="search" id="search" placeholder="Postcode">
</div><br><br><br><br>
<div class="container-register">
<span class="icon"><i class="fa fa-key"></i></span>
<input type="search" id="search" placeholder="Password">
</div><br><br><br><br>
<div class="container-register">
<span class="icon"><i class="fa fa-key"></i></span>
<input type="search" id="search" placeholder="Confirm Password">
</div><br><br><br><br>
<div class="float-middle">
<input type="checkbox" name="checkbox" value="checkbox"> Do you accept our terms & conditions?<br>
</div><br>
<button class="button"><strong>Submit</strong></button>
</form>
</div>
</section></center>
</div>
</div>
Besides using media queries you can use intrinsic units of measurement like vw and vh. Not related to the question but I feel I should point out that #ID must be unique so you can't have every element have id='search'. The type attribute of an <input> determines its behavior so type="search" isn't really what you need. Also there are more suitable tags that you could use other than <div> and <span>, but that's purely optional. I changed the layout a bit to reflect what I previously mentioned.
Demo
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
main {
width: 100vw;
height: 100vh;
}
.icon {
display: inline-block;
margin: 0 0 2vw 2vh;
}
h3 {
margin: 0
}
.line {
border: 0;
width: 96vw;
margin: 0;
padding: 0
}
i {
width: 3vw;
margin: 0 1vw 0 0;
}
.name {
display: block
}
#fullName {
width: 86vw;
}
input {
font: inherit;
width: 39vw;
}
.DOB input {
width: 12vw;
text-align: center;
}
.disclosure {
display: block;
margin: 2vh auto 0;
width: 80vw;
}
#accept {
width: 3vw;
}
[type=submit] {
width: 16vw
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<main>
<form id='register'>
<fieldset id="bg">
<legend>
<h3>
Register
</h3>
</legend>
<label class="icon name"><i class="fa fa-user"></i>
<input type="text" id="fullName" name="fullName" placeholder="Full Name"></label>
<fieldset class='line'>
<label class="icon email"><i class="fa fa-envelope"></i>
<input type="email" id="email" placeholder="Email"></label>
<label class="icon user"><i class="fa fa-user"></i>
<input type="text" id="userName" name="userName" placeholder="Username"></label>
</fieldset>
<fieldset class='line'>
<label class='icon DOB'> <i class="fa fa-birthday-cake"></i>
<input type="number" id="DOBmonth" name="DOBmonth" placeholder="Month" min='1' max='12'>
<input type="number" id="DOBday" name="DOBday" placeholder="Day" min='1' max='31'>
<input type="number" id="DOByear" name="DOByear" placeholder="Year" min='1900' max='2000'></label>
<label class="icon country"><i class="fa fa-map-marker"></i>
<input type="text" id="country" name='country' placeholder="Country"></label>
</fieldset>
<label class="icon pass"><i class="fa fa-key"></i>
<input type="password" id="pass" placeholder="Password">
<input type="password" id="confirm" placeholder="Confirm Password">
</label>
</fieldset>
<label class='disclosure'>
<input type="checkbox" id='accept' name="accept" value="accept"> Do you accept our terms & conditions?
<input type="submit"></label>
</form>
</main>
I'm trying to put a Font-awesome icon inside an input tag.
This is my HTML code:
<div class="input-group">
<input class="form-control" type="password" placeholder="Password">
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
</div>
But that icon is bigger than input box as you can see in this picture:
How can I fix the icon?
Bootstrap 3
Checkout the Bootstrap examples in the Font Awesome documentation:
<div class="input-group margin-bottom-sm">
<span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span>
<input class="form-control" type="text" placeholder="Email address">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
<input class="form-control" type="password" placeholder="Password">
</div>
It should work out of the box, so if you still have height differences, check that there is not other CSS stuff that override your input-group-addon height
Working JSFiddle: https://jsfiddle.net/vs0wpy80
Bootstrap 4
Bootstrap 4 introduced some new classes for input groups, we need to use input-group-prepend and input-group-append:
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-envelope-o fa-fw"></i></span>
</div>
<input class="form-control" type="text" placeholder="Email address">
</div>
<div class="input-group mb-3">
<input class="form-control" type="text" placeholder="Email address">
<div class="input-group-append">
<span class="input-group-text"><i class="fa fa-envelope-o fa-fw"></i></span>
</div>
</div>
Working JSFiddle: https://jsfiddle.net/8do9v4dp/5/
input.form-control{
margin-top: 0;
}
In my case it helps
With CSS only
<div class="wrapper">
<input type="text" class="input">
<i class="icon" class="fas fa-some-icon"></i>
</div>
Wrap the input and the icon in a 2 columns grid with this column template: 1fr 0
.wrapper {
display: grid;
grid-template-columns: 1fr 0;
}
Give the icon a relative position from the right:
.icon{
width: 40px;
position: relative;
right: 45px;
font-size: 35px;
line-height: 40px;
cursor: pointer
z-index: 1;
}
Give the input a nice padding on the margin:
.input{
padding-right: 57px;
}
The input will take 100% of the space in the grid and the icon will float atop.
Works well with responsive designs and you can click on the icon.
I have nested div tags. I want to change their z-index value and make blur which is on back position. But it's not working. I think, in my codes only back div is blurred but my inputs are blurred as well which are located in front div. Thank you for your helps.
.div_front{
background-color: antiquewhite;
}
.div_back
{ border-radius: 5px;
background-color: #f2f2f2;
padding: 20px;
filter: blur(2px);
z-index: -1;
}
<div class="div_back">
<div class="div_front">
<form>
<label for="username"></label>
<input type="text" id="username" name="username" style="text-align:center" placeholder="username">
<label for="password"></label>
<input type="text" id="password" name="password" style="text-align:center" placeholder="password">
<input type="submit" value="Sign In">
<div style="display:flex; padding:0px;">
<input type="submit_reset" value="Forgot password?" style="margin-right:5px;">
<input type="submit_signup" value="Sign Up">
</div>
</form>
</div>
</div>
you can achieve this by putting div_back in absolute position in new .container
check the edit in the HTML
.div_front{
background-color: antiquewhite;
}
.div_back
{ border-radius: 5px;
background-color: #f2f2f2;
filter: blur(2px);
z-index: -1;
position:absolute;
top:0;
right:0;
left:0;
bottom:0;
width:100%;
height:100%;
}
.container{
position:relative;
padding: 20px;
}
<div class='container'>
<div class="div_back">
</div>
<div class="div_front">
<form>
<label for="username"></label>
<input type="text" id="username" name="username" style="text-align:center" placeholder="username">
<label for="password"></label>
<input type="text" id="password" name="password" style="text-align:center" placeholder="password">
<input type="submit" value="Sign In">
<div style="display:flex; padding:0px;">
<input type="submit_reset" value="Forgot password?" style="margin-right:5px;">
<input type="submit_signup" value="Sign Up">
</div>
</form>
</div>
</div>