Style form input login - html

I want to write CSS and HTML to made this input forum from a psd file
I have few questions to ask:
First of all I cutted the background (without the other graphic elements). The header is simple to style. With the input text I found difficult: I would that when an user click over the rectangle, the text and the icon disappear.
this is my css code:
input{
background: url('input-bg.png') no-repeat;
border: none;
width: 303px;
height: 36px;
}
#username{
background: url('user-icon.png') no-repeat left;
}
#password{
background: url('password-icon.png') no-repeat left;
}
where input-bg.png is the following image:
<div id="form-login"><img id="member-icon" src="member-icon.png" />
<h2>Member login</h2>
<ul>
<li><input type="text" id="username" placeholder="User Name"/></li>
<li><input type="password" id="password" placeholder="Password" /></li>
</ul>
</div>
The problem is that the small icons are not showed because the background define of the input text overwite they. There is a simple way so solve this?
There is a simple way to reproduce also the glow effect on the right? i thought about put the effect with a value of the z-index highter than the other elements, but obviously there is a problem if you click over the button or the inputtext in the right of the form. Any suggestion?

I was thinking if its actually possible to make this form in CSS widthgradient, so I gave it a try.
Here's the result: Demo
Its not exactly like the form in picture, byt hey! I am no web designer.
And with some improvements from some CSS genius, you can make it look exactly like the one in picture.
Replace ? icon with the one you want.
HTML
<div class="container"> <!-- Unnecessary tag -->
<div class="form">
<div class="header">
Member Login
</div>
<div class="body">
<form>
<input type="text" placeholder="Username">
<input type="password" placeholder="Password">
<input id="rememberme" type="checkbox">
<label for="rememberme">Remember</label>
<input type="submit" value="Login Now">
</form>
</div>
</div>
</div>
CSS
body {
font-family: helvetica, sans-serif;
}
#font-face {
font-family: 'icons';
src: url('icons.ttf') format('truetype');
}
div, input {
box-sizing: border-box;
}
.container {
width: 500px;
height: 350px;
padding: 35px 0;
background: -webkit-linear-gradient(left, #C2DD9A, #F5FBF0 50%, #C2DD9A);
}
.form {
width: 365px; height: 274px;
margin: auto;
background: rgba(0,0,0,.23);
padding: 2px;
}
.header {
height: 44px;
line-height: 44px;
padding-left: 30px;
font-size: 20px;
background: url('http://i.imgur.com/s0O9hy0.png') 325px center no-repeat, -webkit-linear-gradient(top, rgb(253,253,253), rgb(198,203,199));
}
form {
margin: 0 31px;
}
input[type=text], input[type=password] {
display: block;
width: 100%;
height: 38px;
padding-left: 38px;
background: url('http://i.imgur.com/s0O9hy0.png') 10px center no-repeat, -webkit-linear-gradient(45deg, #404040 0%, #404040 60%, #535353 60%, #494949);
color: #AAA;
border: 1px solid black;
transition: box-shadow .3s;
}
input[type=text]:focus, input[type=password]:focus {
outline: 0;
box-shadow: inset 0 0 8px rgba(226,239,207,.7);
}
input[type=text] { margin-top: 36px; margin-bottom: 26px; }
input[type=password] { margin-bottom: 36px; margin-top: 26px; }
input[type=checkbox] {
-webkit-appearance: none;
width: 11px; height: 11px;
border-radius: 10px;
background: rgba(0,0,0,.5);
margin: 0 5px;
}
input[type=checkbox]:checked {
background: -webkit-radial-gradient(center center, circle, white 0%, white 30%, rgba(0,0,0,.5) 50%);
}
input[type=checkbox] + label {
color: white;
font-size: 15px;
padding-bottom: 3px;
}
input[type=submit] {
float: right;
width: 134px; height: 31px;
border: 1px solid #B7DA7C;
background: url('http://i.imgur.com/s0O9hy0.png') 15px center no-repeat, -webkit-linear-gradient(top, #99CC4B, #73A52C);
font-weight: bold;
color: white;
text-align: right;
padding-right: 22px;
}
input[type=submit]:active {
box-shadow: inset 0 -3 5px rgba(0,0,0,.5);
background: -webkit-linear-gradient(top, #649126, #7DB731);
}

what about using a before statement?
input#username:before{
content: url('user-icon.png');
}
http://www.w3schools.com/cssref/sel_before.asp

the easiest solution would be to add both icon and glow style into input background (different for each input) and then add padding-left to input. KISS rule ;)

Cut out the shade only and make it an absolute positioned div with right: 0; (assuming parent is the form box)
Since elements under the shade box won't be clickable (You will have an rectangle to show triangle), you will have to make invisible divs OVER shade box that will focus input boxes on click.
Order of z-index would be like this:
Input boxes
Shade box
Invisible divs to send focus to input boxes on click
That's what comes first to my mind.

Related

Is it possible to preserve toggles in Inline CSS or do some other trick to send collapsible sections in emails?

I have little experience in HTML so I apologize if this question has already been answered.
I want to send an email that has a few very long sections so I want them to be collapsible. I don't know much html/css but I was able to put something together that collapses the sections. However, whenever I convert it to inline css, I can no longer view the sections that are displayed.
I am open to other ideas on collapseable sections, however, I cannot use regular css, anything that falls under , any javascript, and anything in external documents.
Sample code below
<head>
<style>
body {
font-family: "Open Sans", Arial;
background: #CCC;
}
main {
background: #EEE;
width: auto;
margin: 20px auto;
padding: 10px 0;
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}
h2 {
text-align: center;
}
p {
font-size: 16px;
}
input {
display: none;
visibility: hidden;
}
label {
display: block;
padding: 0.5em;
text-align: center;
border-bottom: 1px solid #CCC;
color: #444;
}
label:hover {
color: #000;
}
label::before {
font-family: Consolas, monaco, monospace;
font-weight: bold;
font-size: 15px;
content: "+";
vertical-align: text-top;
display: inline-block;
width: 20px;
height: 20px;
margin-right: 3px;
background: radial-gradient(ellipse at center, #CCC 50%, transparent 50%);
}
#expand0 {
height: 0px;
overflow: hidden;
transition: height 0.5s;
background: #FFF;
color: #000;
}
section {
padding: 0 20px;
}
#toggle0:checked~#expand0 {
height: 85px;
}
#toggle0:checked~label::before {
content: "-";
}
</style>
</head>
<main>
<input id="toggle0" type="checkbox" checked>
<label for="toggle0">Example</label>
<div id="expand0">
<section>
<p>Hello There</p>
<p>General Kenobi</p>
</section>
</div>
</main>
Inline of Example
<main style="background-color:#EEE;background-image:none;background-repeat:repeat;background-position:top left;background-attachment:scroll;width:auto;margin-top:20px;margin-bottom:20px;margin-right:auto;margin-left:auto;padding-top:10px;padding-bottom:10px;padding-right:0;padding-left:0;box-shadow:0 3px 5px rgba(0, 0, 0, 0.3);" >
<input id="toggle0" type="checkbox" checked style="display:none;visibility:hidden;" >
<label for="toggle0" style="display:block;padding-top:0.5em;padding-bottom:0.5em;padding-right:0.5em;padding-left:0.5em;text-align:center;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#CCC;color:#444;" >Example</label>
<div id="expand0" style="height:0px;overflow:hidden;transition:height 0.5s;background-color:#FFF;background-image:none;background-repeat:repeat;background-position:top left;background-attachment:scroll;color:#000;" >
<section style="padding-top:0;padding-bottom:0;padding-right:20px;padding-left:20px;" >
<p style="font-size:16px;" >Hello There</p>
<p style="font-size:16px;" >General Kenobi</p>
</section>
</div>
</main>
Your example doesn't work because you can't specify inline styles for checked status.
You have to use css for that.
On another note: You say that you want to use this in an email, I don't think any email client would render your collapsible content.
So to answer your question: You have to use CSS (file or tag) for this type of behaviour, it's not possible with inline CSS alone. If you want to send this via email it would be better to dismiss these collapsible elements altogether and maybe reduce the amount of stuff you send out in an email.

How to style file input?

Ok so I got the following:
What I want to do is to make the button which says "Elegir archivos" to be orange like the button that says "Finalizar" and make the text the file-input produces grey like the text which says "Formatos aceptados".
Here's what I tried:
<tr>
<td class="upload-pic"><input class="file-submit" type="file" name="fileUpload" size="50" multiple="multiple"/></td>
</tr>
CSS:
.file-submit {
height: 35px !important;
width: 300px !important;
padding: 5px !important;
font-size: 15px !important;
margin-right: 10px !important;
margin-top: 10px !important;
margin-bottom: 20px !important;
background-color:red;
}
input[type="file"] {
width: 80%;
color: white;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
background-color: #FD8907;
margin-left: 10px;
float: right;
}
What I want: The button which says "Elegir archivos" has to be orange with its text in white. The text next to it which says "No se eligio archivo" has to be grey with the white background. For some reason everything ends up in a big orange box and the button still looks like the default one.
In order to achieve that, you can wrap the input button with "label", so that label becomes clickable. Then make your input button opacity 0 (transparent).
$('.file-submit').on('change', function(){
$(this).closest('.btn-wrapper').find('span')
.text('FOTOS Formatos aceptados: JPG');
})
.btn-wrapper {
font-family: 'Veranda', sans-serif;
}
.btn-file {
padding: 8px 15px;
background-color: #fd8907;
border-radius: 3px;
color: #fff;
margin-right: 8px;
}
.btn-file input[type=file] {
position: absolute;
top: 0;
right: 0;
min-width: 100%;
min-height: 100%;
font-size: 100px;
text-align: right;
filter: alpha(opacity=0);
opacity: 0;
outline: none;
background: white;
cursor: inherit;
display: block;
}
.btn-file span {
display: block;
color: #777;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<td>
<div class="btn-wrapper">
<label class="btn-file">
Elegir archivos
<input type="file" class="file-submit" name="fileUpload" accept=".jpg" multiple="multiple">
</label>
<span>No se eligio archivo</span>
</div>
</td>
But if you want to change the text after file is selected, you will need some help with javascript or jQuery.
Basically what the problem is, that the browser doesn't know that you want it to be orange. Because your file says that it is a button, it is applying the default HTML button style to it. To clear this, in the CSS, all you have to say is:
tr td input.file-submit {
text-decoration: none;
color: #ffffff;
}
Then, just change the color of the text to #848D95.
There you go. Done.
Hope this helps!!!

Remove a hover class from a checkbox once clicked

I am trying to remove a hover class applied to a checkbox via CSS once the box has been clicked.
Does anyone know how to do this?
JSFiddle http://jsfiddle.net/sa9fe/
The checkbox code is:
<div>
<input type="checkbox" id="checkbox-1-1" class="regular-checkbox flaticon-boxing3" />
<input type="checkbox" id="checkbox-1-2" class="regular-checkbox" />
<input type="checkbox" id="checkbox-1-3" class="regular-checkbox" />
<input type="checkbox" id="checkbox-1-4" class="regular-checkbox" />
</div>
And the CSS for the checkbox are as follows:
.regular-checkbox {
vertical-align: middle;
text-align: center;
margin-left: auto;
margin-right: auto;
align: center;
color: #39c;
width: 140px;
height: 140px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
background-color: #fff;
border: solid 1px #ccc;
-webkit-appearance: none;
background-color: #fff;
display: inline-block;
position: relative;}
.regular-checkbox:checked {
background-color: #39c;
color: #fff !important;}
.regular-checkbox:hover {
background-color: #f0f7f9;}
.regular-checkbox:checked:after {
color: #fff;
position: absolute;
top: 0px;
left: 3px;
color: #99a1a7; }
So any suggestions?
Also does anyone know how to change the highlight because at the moment it seems to highlight the edges of the box at a border radius of 3px whereas the boxes I am using are 6px.
So just add this
.regular-checkbox:checked, .regular-checkbox:checked:hover {
background-color: #39c;
color: #fff !important;
}
and if you want remove blue border add outline:0; on your .regular-checkbox class
http://jsfiddle.net/sa9fe/4/
Are you looking for this
.regular-checkbox:checked:hover {
background-color: #39c;
color: #fff !important;
}
Fiddle: http://jsfiddle.net/sa9fe/5/
if you are familiar with jQuery, you can define an onClick event for a particular checkbox and inside of function use removeClass(classname). You can find more at jQuery api site.

How to add button inside input [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
The community is reviewing whether to reopen this question as of 3 days ago.
Improve this question
How do I visually place a button inside an input element as shown below?
The user should be able to interact with the input as normal. The text shouldn't go behind the button, even when it's long. Focus should work correctly. The form should be accessible and work correctly in screen readers. The whole component should be styleable with CSS, and should be able to easily resize to fit the space available.
How do I accomplish this with modern CSS?
The button isn't inside the input. Here:
input[type="text"] {
width: 200px;
height: 20px;
padding-right: 50px;
}
input[type="submit"] {
margin-left: -50px;
height: 20px;
width: 50px;
}
Example: http://jsfiddle.net/s5GVh/
Use a Flexbox, and put the border on the form.
The best way to do this now (2022) is with a flexbox.
Put the border on the containing element (in this case I've used the form, but you could use a div).
Use a flexbox layout to arrange the input and the button side by side. Allow the input to stretch to take up all available space.
Now hide the input by removing its border.
Run the snippet below to see what you get.
form {
/* This bit sets up the horizontal layout */
display:flex;
flex-direction:row;
/* This bit draws the box around it */
border:1px solid grey;
/* I've used padding so you can see the edges of the elements. */
padding:1px;
}
input {
/* Tell the input to use all the available space */
flex-grow:2;
/* And hide the input's outline, so the form looks like the outline */
border:none;
}
/* remove the input focus blue box, it will be in the wrong place. */
input:focus {
outline: none;
}
/* Add the focus effect to the form so it contains the button */
form:focus-within {
outline: 1px solid blue
}
button {
/* Just a little styling to make it pretty */
border:1px solid blue;
background:blue;
color:white;
}
<form>
<input />
<button>Go</button>
</form>
Why this is good
It will stretch to any width.
The button will always be just as big as it needs to be. It won't stretch if the screen is wide, or shrink if the screen is narrow.
The input text will not go behind the button.
Caveats and Browser Support
There's limited Flexbox support in IE9, so the button will not be on the right of the form. IE9 has not been supported by Microsoft for some years now, so I'm personally quite comfortable with this.
I've used minimal styling here. I've left in the padding to show the edges of things. You can obviously make this look however you want it to look with rounded corners, drop shadows, etc..
.flexContainer {
display: flex;
}
.inputField {
flex: 1;
}
<div class="flexContainer">
<input type="password" class="inputField">
<button type="submit"><img src="arrow.png" alt="Arrow Icon"></button>
</div>
I found a great code for you:
HTML
<form class="form-wrapper cf">
<input type="text" placeholder="Search here..." required>
<button type="submit">Search</button>
</form>
CSS
/*Clearing Floats*/
.cf:before, .cf:after {
content:"";
display:table;
}
.cf:after {
clear:both;
}
.cf {
zoom:1;
}
/* Form wrapper styling */
.form-wrapper {
width: 450px;
padding: 15px;
margin: 150px auto 50px auto;
background: #444;
background: rgba(0,0,0,.2);
border-radius: 10px;
box-shadow: 0 1px 1px rgba(0,0,0,.4) inset, 0 1px 0 rgba(255,255,255,.2);
}
/* Form text input */
.form-wrapper input {
width: 330px;
height: 20px;
padding: 10px 5px;
float: left;
font: bold 15px 'lucida sans', 'trebuchet MS', 'Tahoma';
border: 0;
background: #eee;
border-radius: 3px 0 0 3px;
}
.form-wrapper input:focus {
outline: 0;
background: #fff;
box-shadow: 0 0 2px rgba(0,0,0,.8) inset;
}
.form-wrapper input::-webkit-input-placeholder {
color: #999;
font-weight: normal;
font-style: italic;
}
.form-wrapper input:-moz-placeholder {
color: #999;
font-weight: normal;
font-style: italic;
}
.form-wrapper input:-ms-input-placeholder {
color: #999;
font-weight: normal;
font-style: italic;
}
/* Form submit button */
.form-wrapper button {
overflow: visible;
position: relative;
float: right;
border: 0;
padding: 0;
cursor: pointer;
height: 40px;
width: 110px;
font: bold 15px/40px 'lucida sans', 'trebuchet MS', 'Tahoma';
color: #fff;
text-transform: uppercase;
background: #d83c3c;
border-radius: 0 3px 3px 0;
text-shadow: 0 -1px 0 rgba(0, 0 ,0, .3);
}
.form-wrapper button:hover {
background: #e54040;
}
.form-wrapper button:active,
.form-wrapper button:focus {
background: #c42f2f;
outline: 0;
}
.form-wrapper button:before { /* left arrow */
content: '';
position: absolute;
border-width: 8px 8px 8px 0;
border-style: solid solid solid none;
border-color: transparent #d83c3c transparent;
top: 12px;
left: -6px;
}
.form-wrapper button:hover:before {
border-right-color: #e54040;
}
.form-wrapper button:focus:before,
.form-wrapper button:active:before {
border-right-color: #c42f2f;
}
.form-wrapper button::-moz-focus-inner { /* remove extra button spacing for Mozilla Firefox */
border: 0;
padding: 0;
}
Demo: On fiddle
Source: Speckyboy
This is the cleanest way to do in bootstrap v3.
<div class="form-group">
<div class="input-group">
<input type="text" name="search" class="form-control" placeholder="Search">
<span><button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button></span>
</div>
</div>
This can be achieved using inline-block
JS fiddle here
<html>
<body class="body">
<div class="form">
<form class="email-form">
<input type="text" class="input">
Button
</form>
</div>
</body>
</html>
<style>
* {
box-sizing: border-box;
}
.body {
font-family: Arial, sans-serif;
font-size: 14px;
line-height: 20px;
color: #333;
}
.form {
display: block;
margin: 0 0 15px;
}
.email-form {
display: block;
margin-top: 20px;
margin-left: 20px;
}
.button {
height: 40px;
display: inline-block;
padding: 9px 15px;
background-color: grey;
color: white;
border: 0;
line-height: inherit;
text-decoration: none;
cursor: pointer;
}
.input {
display: inline-block;
width: 200px;
height: 40px;
margin-bottom: 0px;
padding: 9px 12px;
color: #333333;
vertical-align: middle;
background-color: #ffffff;
border: 1px solid #cccccc;
margin: 0;
line-height: 1.42857143;
}
</style>

adjusting background color gradient of a submit button with css

Hi i want to style an input submit button which has a background as given in the attached image.The back ground image was provided, but im not sure how to implement it in the submit button so instead of using that image i tried using the css 3 color gradient properties to style the button,however, i cant get the desired color output.Any help is welcome.
CSS code so far.
.button {
-moz-border-radius: 18px;
-moz-box-shadow: #fffff 0px 0px 11px;
-webkit-border-radius: 18px;
-webkit-box-shadow: #6E7849 0 0 10px;
background-color: #fefefefe;
background-image: -moz-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: -ms-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: -o-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: -webkit-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: linear-gradient(24deg, #d8d8d8, #fefefefe);
border-radius: 18px;
border: 1px solid #888888;
box-shadow: #fffff 0px 0px 11px;
color: #000000;
display: inline-block;
font-size: 3em;
margin: auto;
padding: 4px;
text-decoration: none;
}
Use the image. Matching the gradient fully to the image is an unnecessary pain:
.button {
display:block;
width:50px; //use actual image width
height:50px; // use actual image height
background:url(../img/button.png); //image file path
}
.button:hover {
background:url(../img/button_hover.png);
}
To use an image as the input is very simple:
<input type="image"src="/images/submit.gif" />
Finally i found the way to make this button using sliding door technique.However still in jeopardy to style it in disabled state.
This link helped me alot http://www.springload.co.nz/love-the-web/dynamic-submit-buttons
css
div.submit_button {
background: transparent url('common/images/bg-submit2.png') no-repeat 0 0;
display: block;
float: left;
height: 27px; /* total height of the button */
padding-left: 15px; /* end width */
}
span.submit_button_end {
background: #fff url('common/images/bg-submit2.png') no-repeat 100% 0; /* used a sprite image */
display: block;
float: left;
font-weight: normal;
height: 27px; /* total height of the button */
}
input.submit_input {
font-size: 13px;
font-weight:bold;
background: none;
border: none;
padding: 0 0 2px 15px; /* end width */
color: #1b1d60;
cursor: pointer;
position: relative;
height: 25px;
line-height: 25px;
left: -15px;
margin-right: -15px;
padding-right: 15px;
}
input.submit_input:hover {color: #fff;}
div.submit_button:hover {background-position: 0 100%;}
div.submit_button:hover span.submit_button_end {background-position: 100% 100%;}
HTML
<div class='submit_button'>
<span class='submit_button_end'>
<input class='submit_input' type='submit' value='Submit button' tabindex='#' />
</span>
</div>