Input date placeholder - html

I have managed to put the placeholder plus the dd/mm/yyyy together. When I click in order to key in or select the date, the box resets to its default state. Styles like padding, width, and color disappears but when I click outside the box, it returns to default with the styles in place. I would like it to remain the same when selecting the date. Kindly help.
input {
border: 1px solid #ecf0f1;
color: #00A79D;
}
input[type=date] {
text-align: right;
}
input[type="date"]:before {
color: lightgrey;
content: attr(placeholder) !important;
margin-right: 0.3em;
padding: 11px;
}
input[type="date"]:before {
color: lightgrey;
content: attr(placeholder) !important;
margin-right: 0.5em;
}
input[type="date"]:focus:before {
content: '' !important;
color: #00a79d;
}
<div class="col-sm gutters-19">
<div class="form-group">
<div class="form-select-custom">
<input type="date" placeholder="Departure" onchange="this.className=(this.value!=''?'has-value':'')">
</div>
</div>
</div>

This style content: '' !important; is causing the problem:
input[type="date"]:focus:before {
content: '' !important; /* THIS IS THE PROBLEM */
color: #00a79d; /* This is ok */
}
You are removing all the content (i.e. the placeholder word "Departure") and that is what is adding the width and padding.
FYI you are also duplicating the input[type="date"]:before rule, I've combined them into one.
Snippet with that line removed, and you can see it is working:
input {
border: 1px solid #ecf0f1;
color: #00A79D;
}
input[type=date] {
text-align: right;
}
input[type="date"]:before {
color: lightgrey;
content: attr(placeholder) !important;
margin-right: 0.5em;
padding: 11px;
}
input[type="date"]:focus:before {
color: #00a79d;
}
<div class="col-sm gutters-19">
<div class="form-group">
<div class="form-select-custom">
<input type="date" placeholder="Departure" onchange="this.className=(this.value!=''?'has-value':'')">
</div>
</div>
</div>

You shouldn't use ::before on input date elements, since it's heavily browser-specific
Your styles don't disappear : you make your ::before vanish, and it's the thing making the space inside your input. So your input naturally shrinks. Just play with your input[type="date"]:focus::before content, you'll see what i mean.
Not tested, but you could perhaps avoid your javascript toggleClass by using the :empty state. https://developer.mozilla.org/fr/docs/Web/CSS/:empty

simply set width and height to input tag
input{
height: 39px;
width: 237px;
}

Related

Label, Input - shared space (class/div)

i got quite simple thing to do, but i can't find way out for that.
let's say i got form, i want to add inputs one below another, however next to one of them there will be label (only next to one of them).
I would like to make it, so all the classes are equal size (but to make it responsive). However, i would like to make that input with label next to it, to share the space with label, so it will be next to each other, not one under another if user would open that in little screen.
hope you guys got what i mean. :P
Thank you!
EDIT
<div class="mainbox-form">
<form>
<div class="mainbox-input">
<input type="text" name="store-name" placeholder="Name"><br>
</div>
<div class="mainbox-input">
<input type="text" name="store-subdomain" placeholder="Subdomain">
<label name="store-subdomain">.label.here</label><br>
</div>
<div class="mainbox-input">
<input type="email" name="store-email" placeholder="Email"><br>
</div>
<div class="mainbox-input">
<input type="password" name="store-password" placeholder="Password"><br>
</div>
</form>
</div>
.mainbox-form
{
text-align: center;
max-width: 50%;
min-width: 350px;
margin: 0 auto 0 auto;
}
.mainbox-input label
{
font-weight: bold;
color: #606060;
}
.mainbox-input
{
max-height: 57px;
}
.mainbox-input input
{
background: #f3f3f3;
width: 80%;
border: none;
color: #606060;
margin: 3px auto 3px auto;
padding: 15px 40px;
font-size: 18px;
}
.mainbox-input input[name=store-subdomain]
{
max-width: 59%;
}
.mainbox-input input:focus
{
outline: none;
}
.mainbox-input input:active
{
outline: none;
}
http://jsfiddle.net/twjw113w/
Here's the code I've got as for now. The problem I have with it is that, the labeled input is not sticked to the left, and is behaving differently. i bet you can see it yourself better there, than I would explain it.
You need to add display: inline-block and width to the label and input element that you want on the same line.
.mainbox-input label
{
font-weight: bold;
color: #606060;
display:inline-block;
width:35%;
}
.mainbox-input input[name=store-subdomain]
{
max-width: 40%;
display:inline-block;
}
Is this how you wanted it?
jsfiddle
Please remove the css property below:
.mainbox-input{
max-height: 57px;
}
Modify the css below:
.mainbox-input input[name=store-subdomain]{
max-width:100%;
}
.mainbox-input input{
width:auto;
display:table
}
.mainbox-input label{
display: table;
padding: 0px 40px;
}
Visit this url:
http://jsfiddle.net/sarowerj/e41653o4/

css - give bottom border to label & textbox combo

I want to have border to my label text and its associated textbox. I have used border-bottom property but because my label is padded to left its border is not right below it.
html
<div>
<span class="elements">
<label class="field" for="Title">Title</label>
<input name="Title" readonly="readonly" type="text" value="Mr">
</span>
</div>
css
.elements {
padding: 10px;
border-bottom: solid;
border-bottom-color: #1f6a9a;
}
.field {
font-size: 15px;
color: #b6d6ed;
padding-left: 44px;
}
label {
display: inline-block;
width: 80px;
}
input {
background-color: transparent;
border: 0 solid;
height: 25px;
width: 300px;
color: #b6d6ed;
}
jsfiddle : http://jsfiddle.net/2HARy/
I want to have border start from "Title" text only
Remove padding-left: 44px from the .field element and use a margin on the parent element instead. In doing so, the border will start at "title".
Updated Example
.elements {
padding: 10px;
margin-left: 44px;
border-bottom: solid;
border-bottom-color: #1f6a9a;
}
.field {
font-size: 15px;
color: #b6d6ed;
}
Additionally, if you want the border to start directly at the text, remove the padding-left on the .elements element. (example).
Since you have padding-left:44px there is no way to have the border start from the "Title" text. What you must do is remove that property from .elements, wrap .elements in a div, and apply the padding-left property to that div.
Here is a jsfiddle http://jsfiddle.net/3TChG/

Toggle styles on checkbox checked

So, I've been stuck at this for a couple of hours. I'm essentially trying to get a checkbox to work as a toggle button. I want the styles applied by jquery to be only applied when it's checked and back to it's initial if it has been deselected.
The HTML markup:
<form class="simple_form new_mailing_list_form" data-remote="true" id="new_mailing_list_form" method="post">
<div class="input boolean optional mailing_list_form_opt_in">
<input name="mailing_list_form[opt_in]" type="hidden" value="0">
<label class="boolean optional control-label checkbox toggle-button" for="mailing_list_form_opt_in">
<input checked="checked" class="boolean optional" id="mailing_list_form_opt_in" name="mailing_list_form[opt_in]" type="checkbox" value="1">
Yes, I would like to join the mailing list.
</label>
</div>
The SCSS:
#new_mailing_list_form {
.opt {
color: $white;
background-color: $selectiveYellow !important;
border: 2px solid $selectiveYellow !important;
}
.checkbox {
margin: 0px;
padding: 0px;
}
div label input {
margin-right:100px;
}
.mailing_list_form_opt_in label {
cursor: pointer;
background: transparent;
border: 2px solid $selectiveYellow;
border-radius:2px;
font-size: 15px;
font-weight: normal;
line-height: 1.4;
overflow:auto;
margin:4px;
padding: 8px 15px;
width: auto;
&:hover {
background-color: $sunglow;
border: 2px solid $sunglow;
color: $white;
}
}
.mailing_list_form_opt_in label {
display:block;
}
.mailing_list_form_opt_in label input {
display: none;
}
.mailing_list_form_opt_in input:checked {
background-color:$selectiveYellow;
color:$white;
}
}
JQuery:
$('#mailing_list_form_opt_in').change(function () {
$(this).parent().css({ 'background-color':'#ffbb00','border':'2px solid #ffbb00', 'color':'#fff' });
});
I've tried using a conditional statement as well, but I start to descend into spaghetti JQuery which doesn't even work.
Work on it so far: Working CodePen link
You could use jQuery's toggleClass() method to change the background whenever a user clicks the element.
$("#checkbox_elem").on( "click", function(){
$(this).toggleClass( 'background-class' );
});
Now all you have to do is have a default style on the element, and place the new CSS rules into the background-class class definition. Clicking the element will toggle the class on the element.
You could use an explicit check on the element if you want to add some more functionality:
$("#checkbox_elem").on( "click", function(){
if ( $(this).is(':checked') ){
// the checkbox is marked as "checked"
// here you can manipulate the style accordingly
}else{
// the checkbox is NOT marked as "checked"
// here you can manipulate the style accordingly
}
});
So, I'm sharing my pure HTML5/CSS3 solution (which doesn't use any JS/JQuery!) to this problem so that it could be helpful for others stuck on something similar.
I refactored my markup as follows,
HTML:
<input id="mailing_list_form_opt_in" name="mailing_list_form[opt_in]" type="checkbox" value="1">
<label for="mailing_list_form_opt_in">Yes, I would like to join the mailing list.</label>
and for the styles, I used the adjacent selector + & the pseudo class :checked to show the behavior on that state. The corresponding styles for that are as follows,
SCSS:
input[type=checkbox] + label {
background: transparent;
border: 2px solid $selectiveYellow;
border-radius: 2px;
-webkit-font-smoothing: subpixel-antialiased;
font-size: 15px;
font-weight: normal;
line-height: 1.4;
overflow: auto;
margin: 4px;
padding: 8px 15px;
#include transition( 0.25s linear);
width: auto;
&:hover {
background-color: $sunglow;
border: 2px solid $sunglow;
color: $white;
}
}
input[type=checkbox]:checked + label {
background: $selectiveYellow !important;
border: 2px solid $selectiveYellow !important;
color: $white;
}
input[type=checkbox] {
display: none;
}
Works perfectly, added a Codepen so that you can check that out as well! Hope this helps others! :D

Fieldset loses styling in print view

There is information displayed in a fieldset that is taken from a database in a content management system.
The information is styled correctly when viewed as a normal page, however when the page is viewed in print preview, the information in the fieldset is aligned to the left of the page and the styling is lost!
I have looked everywhere for a solution, people have mentioned removing the floats etc, however I can't seem to solve this problem!
The problem seems to occur in all browsers I have tried (Safari, Chrome and Firefox).
There is a small amount of data presented in a table, which is formatted correctly :/
View from page:
page view
View from print preview:
print view
Any help would be greatly appreciated!
EDIT: These are small snippets of code as requested - there is a lot there!
HTML
<div class="divClass" id="Person_title_div" >
<label class="divLabel" for='Person_title' id="Person_title.label"
>Title </label>
<div class="divValue">
<input type="hidden" name="Person.title" value="-5509180968589174739" />
<span >Dr</span>
</div>
</div>
<div class="divClass" id="Person_knownAs_div" >
<label class="divLabel" for='Person_knownAs' id="Person_knownAs.label"
>Name </label>
<div class="divValue">
<span >qwe qwe</span>
</div>
</div>
<div class="divClass" id="Person_email_div" >
<label class="divLabel" for='Person_email' id="Person_email.label"
>Email </label>
<div class="divValue">
<span >qwe#qew</span>
</div>
</div>
CSS
div.divClass,
div.formWidget,
div.multiList {
float: left;
position:relative;
margin:0 5px 5px 0;
min-height:30px;
width:310px;
}
fieldset {
clear: both;
border: 1px solid #888;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}
print.css
/* print styles */
body { background: white; font-size: 8pt; font-family: Verdana, Arial; }
#firstMenu,
#secondMenu,
#additionalMenu,
#footernav,
#selectheader ul,
input,
a img#logo { width: 58px; height: 70px; }
a:link, a:visited { color: #520; background: transparent; font-weight: normal; text-decoration: none; }
header { height: 105px; background: url(images/header.gif) no-repeat; }
div#mainData td, div#mainData th { float: none !important; display: inline !important; padding-left: 1em; padding-right: 1em; }
table.datatable th, table.datatable td {
vertical-align: top;
/*For some reason table text is coming out inconsistent. Must be being inherited somewhere,
but difficult to pin down. Therefore force to specific pixel value as a work around */
font-size: 9px;
}/* CSS Document */
.menu {
display: none; }
.session {
display: none; }

How can I control the height of text inputs and submit input buttons in different browsers?

I have a very little but hard (for me) problem to solve.
I have a text input, and a submit button. I need them to be the exact same height and for this to be true across Chrome and Firefox, ideally internet explorer also.
HTML
<input type="text" name="email" /><input type="submit" value="»" />
CSS
input[type=text] {
width: 218px;
}
input[type=submit] {
background: #000;
color: #fff;
}
input[type=submit], input[type=text] {
padding: 9px;
font-size: 18px;
line-height: 18px;
float: left;
border: 0;
display: block;
margin: 0;
}
I've setup this basic code on a jsfiddle here.
You should notice if you load it in chrome, the button is less height than the text input and in firefox, its larger.
What am I missing?
Remove/add line-height: 18px; for both.
Vertical padding of the submit button has no effect. This seems to be a webkit bug. You can solve the problem by specifying explit heights and increasing the height of the submit button by the top and bottom padding of the input field.
input[type=text] {height: 60px;}
input[type=submit] {height: 78px;}
The problem is your padding that is applying wrong to your button.
Trying solving it like this.
input[type=submit], input[type=text] {
font-size: 18px;
line-height: 18px;
float: left;
border: 0;
display: block;
margin: 0;
height: 30px; /* or whatever height necessary */
}
Additionally, you can keep the padding left and right on your button like this.
input[type=submit] {
background: #000;
color: #fff;
padding: 0px 9px;
}
input {
height: 19px;
}
This maybe?
Also, remove the padding property.
http://jsfiddle.net/xkeshav/e6aTd/1/
Maybe it's the padding that is making problems. Try removing the padding, setting the button to a fixed height and make the offset with line-height.
You need to remove the height and work on the actual height of the input text field just by padding/font-size
jsfiddle
Removing/adding line-height: 18px; for both is not a perfect solution because I see a little difference height in firefox...
The best solution I found is to put a div arround and set its style to display: flex.
All is perfect this way.
body {
background: #ccc;
}
div{
display: flex;
}
input[type=text] {
width: 218px;
}
input[type=submit] {
background: #000;
color: #fff;
}
input[type=submit], input[type=text] {
padding: 5px;
font-size: 25px;
border: 0;
margin: 0;
}
<div><input type="text" name="email" /><input type="submit" value="»" /></div>
TRY
body {
background-color: #ccc;
}
input[type=text] {
width: 218px;
}
Working DEMO