css on different input classes - html

hello i have the following problem:
i do check my form for some php error messages.
in case of no error i simply have my css setting:
.wrapper #frame form fieldset ul input {
color: #f23;
font-size: 10px;
height: 18px;
padding-left: 5px;
margin-top: 3px;
outline:none;
}
and my focus settings:
.wrapper #frame form fieldset ul input:focus{
color:#fff;
font-weight: bold;
border: 2px solid #fff;
}
okay, now i changed this line:
<input type="text" id="normal" name="1" value=""/>
with adding the class of error:
<input class="err" type="text" id="normal" name="1" value=""/>
the problem is that my settings just take place for my class details on the input fields but not on my focus settings:
.err {
color: #444444;
font-size: 10px;
width: 180px;
height: 18px;
padding-left: 5px;
outline:none;
background-image: url(../images/error.png);
}
.err input:focus{
color:#f23;
font-weight: bold;
border: 2px solid #f23;
}
so if there is someone who could tell me why this does not work i really would appreciate. thanks a lot.

You have a class of error in your HTML, and in your CSS you've set the class to err; if you use the same name consistently (whichever you choose) it should work.
Your current HTML:
<input class="error" type="text" id="normal" name="1" value=""/>
...and CSS:
.err {
color: #444444;
font-size: 10px;
width: 180px;
height: 18px;
padding-left: 5px;
outline:none;
background-image: url(../images/error.png);
}
.err input:focus{
color:#f23;
font-weight: bold;
border: 2px solid #f23;
}
Also, in your CSS you're selecting an input that's a descendant of an element with the err class-name, not an input element with that class-name. So, altogether you should use something like:
<input class="err" type="text" id="normal" name="1" value=""/>
input.err {
color: #444444;
font-size: 10px;
width: 180px;
height: 18px;
padding-left: 5px;
outline:none;
background-image: url(../images/error.png);
}
input.err:focus{
color:#f23;
font-weight: bold;
border: 2px solid #f23;
}

Related

How to reposition a misplaced cursor/blinker in the textarea?

I have an issue where the cursor/blinker is right in the top left of the textarea with no margin or whatsoever. I don't know what could be causing this, the other inputs are working fine. Here is a screen shot:
I also wanna know how to change that black border color? I would like the border to stay the same when I click on it. I tried using textarea:focus to get rid of it but it's not working.
Lastly I wanna get rid of this whitish background when a form gets auto-completed, I haven't figured out how to get rid:
HTML:
<form class="form appear appear-hidden" method="post">
<h1>Contact Me</h1>
<div class="name-section">
<input type="name" placeholder="Name" required />
<input type="surname" placeholder="Surname" required />
</div>
<input type="email" placeholder="Email" required />
<textarea
class="message"
type="message"
placeholder="Message"
row="4"
required
></textarea>
<input class="submit" type="submit" placeholder="submit" />
</form>
CSS:
.name-section input {
width: 48%;
margin: 5px;
border: 2px solid white;
padding: 10px;
background-color: transparent;
font-weight: 600;
}
form input {
width: 98%;
margin: 5px;
border: 2px solid white;
padding: 10px;
/* background-color: #000; */
background-color: transparent;
font-weight: 600;
color: white;
font-family: 'Poppins', sans-serif;
}
input::placeholder {
font-family: 'Poppins', sans-serif;
color: white;
font-weight: 600;
}
input:focus {
border: 1px solid white;
}
textarea {
min-height: 100px;
background-color: transparent;
color: white;
font-family: 'Poppins', sans-serif;
width: 98%;
margin: 5px;
border: 2px solid white;
resize: none;
font-weight: 600;
}
textarea::placeholder {
color: white;
padding: 10px;
margin: 10px;
font-weight: 600;
}
Thanks in advance for the help.
You have no padding in your Textaria, try this: remove padding from textarea::placeholder and add padding to .message :
textarea::placeholder {
margin: 10px;
font-weight: 600;
}
.message{
padding:10px;
}
To remove the "black-border-color:
input:focus{
outline:solid 3px blue;
}
I didn't understand what you mean by this: "Lastly I wanna get rid of this whitish background when a form gets auto-completed, I haven't figured out how to get rid:"

Is there a way in CSS to make a label get a different property when an input is focused without using JS? [duplicate]

This question already has answers here:
Is there a "previous sibling" selector?
(30 answers)
Closed 1 year ago.
What I am trying to do is change the label font color and border color when the input field is focused. Is there a way to make that happen without using JavaScript?
.input-label {
display: flex;
align-items: center;
height: 16px;
font-weight: 700;
font-size: 11px;
letter-spacing: .1px;
color: #989898;
text-transform: uppercase;
}
.form-control{
display: inline-block;
max-width: 100%;
word-wrap: normal;
background: transparent;
border: none;
border-bottom: 2px solid #cacaca;
color: #4a4a4a;
font-size: 1.19em;
height: 35px;
letter-spacing: .2px;
padding: 7px 0;
width: 100%;
resize: none;
}
input:focus{
/* after the input is focused the labele font color and border color change to something else*/
}
<div class="firstname">
<label for="name" class="input-label" id="name-label">First Name</label>
<input type="text" class="form-control" id="name" placeholder="First Name" required>
</div>
You can use the :focus-within pseudo-class:
matches an element if the element or any of its descendants are focused.
You might want to check if the browser compatibility fits your requirements at caniuse.com
And create a selector like this:
.firstname:focus-within .input-label {
color: red;
}
.input-label {
display: flex;
align-items: center;
height: 16px;
font-weight: 700;
font-size: 11px;
letter-spacing: .1px;
color: #989898;
text-transform: uppercase;
}
.form-control {
display: inline-block;
max-width: 100%;
word-wrap: normal;
background: transparent;
border: none;
border-bottom: 2px solid #cacaca;
color: #4a4a4a;
font-size: 1.19em;
height: 35px;
letter-spacing: .2px;
padding: 7px 0;
width: 100%;
resize: none;
}
.firstname:focus-within .input-label {
color: red;
}
<div class="firstname">
<label for="name" class="input-label" id="name-label">First Name</label>
<input type="text" class="form-control" id="name" placeholder="First Name" required>
</div>
Alternatively, you could place your label after the input and reorder them using CSS.
CSS does not have selectors to climb up the DOM tree, to use CSS to modify style of an element from another one being focused, it has to stand ahead as a sibling or a parent.
But it has flex or grid with order that allows to reorder elements at screen, so you can rewrite your HTML and set the label right behind the input and still show it , print it ahead that input.
Here is an example with grid (builds a grid of 1 single column if not set otherwise) and order.
.firstname {
display: grid;
}
.input-label {
display: flex;
align-items: center;
height: 16px;
font-weight: 700;
font-size: 11px;
letter-spacing: .1px;
color: #989898;
text-transform: uppercase;
order: -1;
}
.form-control {
display: inline-block;
max-width: 100%;
word-wrap: normal;
background: transparent;
border: none;
border-bottom: 2px solid #cacaca;
color: #4a4a4a;
font-size: 1.19em;
height: 35px;
letter-spacing: .2px;
padding: 7px 0;
width: 100%;
resize: none;
}
input:focus+label {
color: red;
}
<div class="firstname">
<input type="text" class="form-control" id="name" placeholder="First Name" required>
<label for="name" class="input-label" id="name-label">First Name</label>
</div>
https://developer.mozilla.org/en-US/docs/Web/CSS/order
The order CSS property sets the order to lay out an item in a flex or grid container. Items in a container are sorted by ascending order value and then by their source code order.
If you have a single duo of input/label within the form, then within-focus is the easiest option.
So in html, just let the label empty and put input first and label in second.
Then here is the CSS. The goal is to use css selector + to put label back as first position.
Then you change the label css how you wish :
/* CSS ADDED */
.firstname{
display:flex;
}
.firstname > *:last-child {
order:-1;
}
input:focus + label{
color: red;
border: 3px solid red;
padding: 5px;
}
DEMO:
.input-label {
display: flex;
align-items: center;
height: 16px;
font-weight: 700;
font-size: 11px;
letter-spacing: .1px;
color: #989898;
text-transform: uppercase;
}
.form-control{
display: inline-block;
max-width: 100%;
word-wrap: normal;
background: transparent;
border: none;
border-bottom: 2px solid #cacaca;
color: #4a4a4a;
font-size: 1.19em;
height: 35px;
letter-spacing: .2px;
padding: 7px 0;
width: 100%;
resize: none;
}
/* CSS ADDED */
.firstname{
display:flex;
flex-direction: column;
}
.firstname > *:last-child {
order:-1;
}
input:focus + label{
color: red;
border: 3px solid red;
padding: 5px;
}
<div class="firstname">
<input type="text" class="form-control" id="name" placeholder="First Name" required>
<label for="name" class="input-label" id="name-label">First Name</label>
</div>

How can I set the spacing between input elements in CSS?

How can I make the Email and Password fields separated by the exact height of their icons? I tried using line-height but it only seems to work on text.
Of course I could simply look at the height of the icon in Firefox's Web Inspector and then say margin-bottom: xx px, but is that really the best way to do it?
My code looks like this:
<form class="signup-field">
<h1>Enter your email to start.</h1>
<h2>Choose a strong password.</h2>
<div class="input-group">
<span class="input-group-addon"></span>
<input type="text" class="form-control" placeholder="Email" /><br />
</div>
<div class="input-group">
<span class="input-group-addon"></span>
<input type="password" class="form-control" placeholder="Password" /><br />
</div>
<div class="input-group t-c-submit">
<input type="checkbox">I agree to the terms and conditions.
<button type="button" class="button">Get Started</button>
</div>
</form>
and my CSS looks like this:
#font-face {
font-family: "simple-line";
src: url("simple-line-icons-24.woff") format('woff');
}
.container {
max-width: 880px;
}
.signup {
background-color: #48b7d6;
color: #fff;
font-family: Montserrat;
}
.signup h1 {
font-size: 3.2em;
}
.signup h2 {
font-size: 1.188em;
}
.signup-field input {
background: none;
border-left: none;
border-right: none;
border-top: none;
border-bottom: 1px dotted #dce3e7;
margin: 10px;
color: #fff;
}
.signup-field input::placeholder {
color: #fff;
}
.signup-field button {
float:right;
font-size: 1.188em;
background: none;
color: #fff;
border: 1px solid #dce3e7;
margin: 12px;
min-width: 140px
}
.signup-field button:hover {
background-color: #2fa1ba;
}
.signup-field .input-group-addon {
font-family: simple-line;
font-size: 1.188em;
border: 1px solid #dce3e7;
background: none;
border-radius: 0;
color: #fff;
}
/* Bootstrap overrides (also the above 3 lines) */
.input-group {
width: 100%;
line-height: 200%;
}

Font Awesome with easyAutocomplete plugin

I have a form in which I want to show the input text field and submit on the same line. The input text field has two FontAwesome icons which I want to show inside the text field. I can style the form as I want when I don't use the easy Autocomplete plugin. But when I activate the easyAutocomplete plugin, the styling goes haywire.
Here's the code:
HTML:
<form role="search" method="get" id="searchform" class="searchform" action="">
<span class="fa fa-map-marker my-fa"></span>
<input type="text" value="" name="s" id="search-input" class="s" placeholder="Enter your Postcode" autocomplete="off">
<img id="slider-loading" class="loading" src="https://www.imageupload.co.uk/images/2017/02/05/gps2.gif" />
<input type="hidden" value="profile" name="post_type" id="post_type" />
<input type="hidden" value="country" name="taxonomy" />
<input type="submit" id="searchsubmit" value="GO" class="submit btn" />
</form>
jQuery
var options = {
data: ["Cyclops", "Storm", "Mystique", "Wolverine", "Professor X", "Magneto"],
theme: "dark"
};
$("#search-input").easyAutocomplete(options);
CSS:
.searchform {
position: relative;
text-align: center;
}
.searchform input[type="text"] {
width: 400px;
font-size: 15px;
margin: 0px -3px 0px 0px;
text-indent: 18px;
padding: 15px;
text-transform: uppercase;
letter-spacing: 1px;
font-weight: 300;
font-family: 'Raleway', sans-serif;
border: solid 1px #bbb;
overflow: hidden;
border-radius: 4px;
}
.searchform input[type=text],
.searchform input[type=text]:focus {
outline: none;
}
.searchform input[type=text]:focus {
border: none;
}
.searchform input[type="submit"] {
background-color: #f70808;
-webkit-box-shadow: 0 2px 0 #c60606;
-moz-box-shadow: 0 2px 0 #c60606;
box-shadow: 0 2px 0 #c60606;
color: white;
border: none;
letter-spacing: 1px;
padding: 15px;
font-size: 15px;
text-align: center;
}
.searchform input[type="submit"],
.searchform input[type="text"] {
line-height: normal !important;
display: inline-block;
}
.my-fa {
font-family: 'FontAwesome';
position: absolute;
z-index: 2;
color: #f70808;
font-size: 2.8em;
margin-left: 4px;
top: 4px;
}
#slider-loading {
position: relative;
top: 12px;
right: 35px;
}
I want to show the map icon on the left of the input text field and and the loading spinner on the right of the input text field.
JSFiddle - with easyAutocomplete plugin
JsFiddle - without the plugin
You could add the following code to your CSS:
.easy-autocomplete{
display:inline;
}
I think it gives you the desired outcome.
The plugin wraps the input in a div which by default have display:block and it throws the other elements out of line.
You may need to adjust the padding/margin to your preference.
See updated fiddle

Align labels to left on form using CSS

I have a login form with labels and input, i can not get the labels to go on the left and input on the right. Currently they are sitting on top of each other.
Here is the HTML:
<div class="login">
<form name="login" action="submit" method="get" accept- charset="utf-8">
<label for="usermail">Username</label>
<input type="email" name="usermail" placeholder="yourname#email.com" required>
<label for="password">Password</label>
<input type="password" name="password" placeholder="password" required>
<input type="submit" value="Login">
</form>
</div>
Here is the CSS:
form {
margin:auto;
position:relative;
width:375px;
height:250px;
font-family: Lucida Sans, Geneva, sans-serif;
font-size: 14px;
font-style: italic;
line-height: 24px;
font-weight: bold;
text-decoration: none;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding:10px;
border: 1px solid #999;
border: inset 1px solid #333;
}
input { float:right;
width:350px;
display:block;
border: 1px solid #999;
height: 25px;
}
Here is the JSFiddle https://jsfiddle.net/ojz87d0x/
On input, change display:block; to display:inline-block;, and add the following:
label {
display: inline-block;
float:left;
clear:both;
}
input[type="submit"] {
clear: both;
}
You'll also need to make sure that the width of the input and the width of the form are different enough to allow space for the label. In this example [in the fiddle]. I set input to 275px and form to 375px.
Here's a newer update to your fiddle.
First of all, the inputs are too wide for both the labels and inputs to be next to each other inside the form. So either widen the form or shorten the inputs.
Next, add float: left to the labels.
form {
margin: auto;
position: relative;
width: 375px;
height: 250px;
font-family: Lucida Sans, Geneva, sans-serif;
font-size: 14px;
font-style: italic;
line-height: 24px;
font-weight: bold;
text-decoration: none;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding: 10px;
border: 1px solid #999;
border: inset 1px solid #333;
}
input {
float: right;
width: 300px; /*smaller width*/
display: block;
border: 1px solid #999;
height: 25px;
}
label {
float: left;
margin-top: 3px;
<div class="login">
<form name="login" action="submit" method="get" accept- charset="utf-8">
<label for="usermail">Username</label>
<input type="email" name="usermail" placeholder="yourname#email.com" required>
<label for="password">Password</label>
<input type="password" name="password" placeholder="password" required>
<input type="submit" value="Login">
</form>
</div>