Input field glows in Firefox without focus - css

I've run into a strange issue that only affects Firefox. All form fields display as I expect them to (that is to say, with thin 1px borders which change colour based on the current validation state of the input value) except for one specific field inside a reCAPTCHA widget, which has a persistent red glow around it until text has been added. Note that this is the ONLY field in this form which has this effect, and it isn't coming from any of my styles--I've checked the computed styles and there's nothing to explain this.
I've already applied outline: 0px none transparent; and -moz-appearance: none; to this elements without success. Thoughts?
SASS:
input, textarea, select {
padding: 0.35em 0.5em;
width: 100%;
max-width: 100%;
border: 0.1em solid #C5C5C5;
background: #FFFFFF none left center no-repeat;
// Add a subtle grey tone to the the text when not focused
color: darken(#C5C5C5, 25%);
// Nice transitions to smooth out the experience
-webkit-transition: border-width 0.1s ease-in-out, border-color 0.1s, background 0.1s;
-moz-transition: border-width 0.1s ease-in-out, border-color 0.1s, background 0.1s;
transition: border-width 0.1s ease-in-out, border-color 0.1s, background 0.1s;
-moz-appearance: none !important;
outline:0px none transparent !important;
&:focus {
// border-color: #000000;
border-left-width: 0.25em;
border-color: $info;
color: $base-font;
background-image: url("../img/info-arrow.png");
outline:0px none transparent !important;
&:invalid {
border-color: $error;
background-image: url("../img/required-arrow.png");
}
&:valid {
border-color: $success;
background-image: url("../img/success-arrow.png");
}
&:optional {
border-color: $info;
background-image: url("../img/info-arrow.png");
}
}
&[disabled] {
background-color: $gray;
color: darken($gray, 50%);
}
}
HTML:
<div class="field-captcha"> <div id="recaptcha_widget" style="display:none" class="recaptcha_widget">
<div id="recaptcha_image"></div>
<div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect. Please try again.</div>
<div class="recaptcha_input">
<label class="recaptcha_only_if_image" for="recaptcha_response_field">Enter the words above:</label>
<label class="recaptcha_only_if_audio" for="recaptcha_response_field">Enter the numbers you hear:</label>
<input type="text" id="recaptcha_response_field" name="recaptcha_response_field" required>
</div>
<ul class="recaptcha_options">
<li class="recaptcha-link">Powered by reCAPTCHA</li>
<li class="new-captcha">
<a href="javascript:Recaptcha.reload()">
<span class="captcha-hide">Get another CAPTCHA</span>
</a>
</li>
<li class="new-captcha audio-captcha recaptcha_only_if_image">
<a href="javascript:Recaptcha.switch_type('audio')">
<span class="captcha-hide">Get an audio CAPTCHA</span>
</a>
</li>
<li class="new-captcha image-captcha recaptcha_only_if_audio">
<a href="javascript:Recaptcha.switch_type('image')">
<span class="captcha-hide"> Get an image CAPTCHA</span>
</a>
</li>
<li class="help">
<a href="javascript:Recaptcha.showhelp()">
<i class="icon-question-sign"></i><span class="captcha-hide"> Help</span>
</a>
</li>
</ul>
</div>
EDIT: Added SASS and relevant HTML to question

Following Steven Don's noting that it was a box-shadow effect I tried adding box-shadow: none to all inputs and textareas and it overrode the default Firefox styling causing this red glow effect. For the curious, here were the actual rules causing the effect (from forms.css):
:-moz-ui-invalid:-moz-focusring:not(output) {
box-shadow: 0px 0px 2px 2px rgba(255,0,0,0.4);
}
:-moz-ui-invalid:not(output) {
box-shadow: 0px 0px 1.5px 1px red;
}
Since they're from the browser stylesheet they're easy to override with even a basic element selector, which is what I've done here. Either way it resolves this particular cross-browser display issue.

Related

Why doesn't Safari 13 paint/render outline on focus when transition is used

Focusing on the button in the example below in safari 13.0.5 will not show the outline until you force a repaint (for example by changing the screen size)
Works fine in other browsers
Is there any hacks to get the outline to show up in Safari for this case?
button {
width: 10em;
height: 3em;
transition: all .25s ease-in-out;
}
button:focus {
outline : 2px blue dashed;
}
<button type="button">Button</button>
Interestingly, a large enough negative offset for the outline will bypass this bug.
Unfortunately that may not work in all my cases so I am hoping for a better answer.
button {
width: 10em;
height: 3em;
transition: all .25s ease-in-out;
}
button:focus {
outline : 2px blue dashed;
outline-offset: -2px;
}
<button type="button">Button</button>
As of Safari 13.1 this issue is no longer reproducible!
Thats a known safari issue.
The problem is, that you can't focus the button element in safari.
It's not even possible with the tabindex attribute.
See some resources:
resource 1
resource 2
A, maybe, possible solution could be something like this (change the button element to, for example, a div with a class):
.button {
width: 10em;
height: 3em;
transition: all .25s ease-in-out;
}
.button:focus {
outline : 2px blue dashed;
outline-offset: -2px;
}
<div class="button" tabindex="0">Button</div>
Even in this example, you have to set the tabindex attribute for safari..

Make border-bottom disappear on hover with pseudo

Make border-bottom disappear on hover.
<a id="toggle" href="#modal0">living in New York,</a>
#toggle {
transition: all .3s ease-out;
position: relative;
}
#toggle::after{
content:'';
position:absolute;
width: 100%;
height: 0;
left:0;
bottom: 4px; /* <- distance */
border-bottom: 2px solid #000;
}
#toggle::after:hover{
transition: all .3s ease-out;
border-bottom: solid transparent 1px
}
Changed pseudo hover as suggested
#toggle:hover::after{
border-bottom: 1px transparent #999;
transition: all .3s ease-out;
}
You need to add position:relative to #toggle. This will make the positioning of the ::after pseudo-element relative to the element's position.
Edit
Per the update, you need to switch the ::after and the :hover, so #toggle:hover::after. That way it's "the after pseudo-element, of the #toggle when hovered".
You could set the display property of your a-element to inline-block and set the height property to something like 0.9em to move the bottom border closer, eg.
<a id="toggle" href="#modal0" style="display:inline-block;height:0.9em;">living in New York,</a>

Adding "active" color for custom Kendo UI grid button

I'm trying to add a colorful custom button to a Kendo UI grid.
It works great except for the active state. Background color doesnt get overrided.
HTML:
<a class="k-button k-button-icontext k-grid-details" href="#">
<span class=" "></span>
Details</a>
CSS:
.k-grid-details {
color: #fff;
padding-left: 10px;
padding-right: 10px;
width: 50px;
border-color: #003399;
background-color: #003399;
background: linear-gradient(#003399, #000167);
}
.k-grid-details:hover {
border-color: #003399;
color: #fff;
background-color: #003399;
}
.k-grid-details .k-state-active,
.k-grid-details:active {
background-color: #003399;
}
What might be missing?
Look at this FIDDLE
your problem is that you are using background + background-color in your .k-grid-details
but when you hover and active the .k-grid-details just do the background-color, therefore the background (which contains linear-gradient(#003399, #000167))stays on hover and active state. so you must join background-color and background, making it shorthand, like this:
background: #039 linear-gradient(#003399, #000167)
you can see more for background shorthand HERE
then in your hover and active state just after the background color, you set none for the linear-gradient, like this:
.k-grid-details:hover {
background: #ff0 none;
}
.k-grid-details:active {
background: #f00 none;
}

Bootstrap add focus and validation states to input-group-addon, not just input

In Bootstrap, when you :focus on an input it adds a blue border and box shadow to indicate the focus.
For validation states (error, warning, success), it adds a red, yellow, and green border to the input respectively.
However, if you have placed an input-group-addon to the input field, the addon does not focus. Creating a somewhat weird effect:
How can I add the focus to the addon?
Here is how I managed to do this just by CSS
.input-group:focus-within .input-group-prepend .input-group-text,
.form-control:focus ~ .input-group-append .input-group-text {
border-color: #06f;
}
Unfortunately, I couldn't figure out a way to do it without javascript. But here's a solution.
Add this CSS:
.input-group-focus {
border-radius:4px;
-webkit-transition: box-shadow ease-in-out .15s;
transition: box-shadow ease-in-out .15s;
}
.input-group-addon {
-webkit-transition: border-color ease-in-out .15s;
transition: border-color ease-in-out .15s;
}
.input-group.input-group-focus {
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6) !important;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6) !important;
}
.has-error.input-group.input-group-focus,
.has-error .input-group.input-group-focus {
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483 !important;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483 !important;
}
.has-warning.input-group.input-group-focus,
.has-warning .input-group.input-group-focus {
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168 !important;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168 !important;
}
.has-success .input-group.input-group-focus,
.has-success .input-group.input-group-focus {
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #c0a16b !important;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #c0a16b !important;
}
.input-group-focus input:focus {
-webkit-box-shadow: none !important;
box-shadow: none !important;
}
.input-group-focus .input-group-addon {
border-color: #66afe9 !important;
}
.has-error .input-group-addon {
border-color: #843534 !important;
}
.has-success .input-group-addon {
border-color: #2b542c !important;
}
.has-warning .input-group-addon {
border-color: #66512c !important;
}
The !important's may or may not be necessary for your implementation, so I decided to leave them there. I don't think there's a scenario where something is more important than your focus state, so it should be okay.
And the JS (uses jQuery):
$(document).ready(function() {
$(".input-group > input").focus(function(e){
$(this).parent().addClass("input-group-focus");
}).blur(function(e){
$(this).parent().removeClass("input-group-focus");
});
});
This will work whether you add validation states to the .input-group parent or the .form-group parent.
The resulting effect:
Depicted above, my solution (using Bootstrap 4) is to overlap the input-group-addon on top of the input with absolute positioning and z-index. I add some right padding to the input to make room for the addon. Here's my SCSS and markup:
.input-group.input-group-seamless-append {
> input {
width: 100%;
padding-right: 52px;
}
> .input-group-append {
position: absolute;
right: 1px;
top: 1px;
bottom: 1px;
z-index: 4;
}
}
<div class="input-group input-group-seamless-append">
<input autocomplete="off" class="form-control rounded"
aria-describedby="button-addon"
[attr.type]="showPassword ? 'text' : 'password'">
<div class="input-group-append">
<button type="button" id="button-addon"
class="btn btn-light shadow-none border-0 bg-transparent text-primary">
<i class="fa fa-eye" *ngIf="showPassword"
(click)="showPassword = !showPassword"></i>
<i class="fa fa-eye-slash" *ngIf="!showPassword"
(click)="showPassword = !showPassword"></i>
</button>
</div>
</div>
You can see this special UX is activated by adding the class input-group-seamless-append to my input-group, so I can control specific places it is applied.
If you're not using Angular you'll need to remove the (click), *ngIf, and [attr] bindings, those are specific to show/hide password functionality.
Here's what it ends up looking like:
Unfocused:
Focused:
I don't really like using JQuery these days at the best of times, and find javascript solutions can become a hard to support (happy to be corrected :)
From what we know with CSS the + operator will apply rules to the very next child selector or we can use ~ to target any child selector. (It is annoying there's no parent selector)
With this in mind my solution (only tested with Chrome and not with the .has-success, .has-errors etc states on .form-group) is to over lay a modified copy of the .input-group block, nested within it self.
The base block would be something like:
<div class="form-group">
<label class="control-label">Input with addons</label>
<div class="input-group">
<div class="input-group-addon">$</div>
<input type="text" class="form-control" placeholder="placeholder text">
<div class="input-group-addon">.00</div>
</div>
<span class="help-block">Help block</span>
</div>
The modified / duplicate block (which is added / inserted just after the input field in the above code):
<div class="input-group-overlay">
<div class="input-group-addon">$</div>
<span class="form-control"></span>
<div class="input-group-addon">.00</div>
</div>
The complete block now looks like:
<div class="form-group">
<label class="control-label">Input with addons</label>
<div class="input-group">
<div class="input-group-addon">$</div>
<input type="text" class="form-control" placeholder="placeholder text">
<div class="input-group-overlay">
<div class="input-group-addon">$</div>
<span class="form-control"></span>
<div class="input-group-addon">.00</div>
</div>
<div class="input-group-addon">.00</div>
</div>
<span class="help-block">Help block</span>
</div>
The block needs to go before the last input-group-addon if there's appended elements otherwise the top and bottom right radius corners won't be applied. I've also used + as the operator in the below CSS, which expects it to be the very next element.
Now the CSS:
input:focus + .input-group-overlay .input-group-addon {
border-color: #66afe9;
}
.input-group-overlay {
position: absolute;
display: inherit;
z-index: 1;
top: 0;
left: 0;
}
This will apply the border to the child input addon's that over lap the the parent elements.
As stated at the top, this has only been tested in Chrome, the z-index for the span .form-group might need some tweaking in other browsers.
Added bounce, you can also remove the left and right borders of the input to and change the background colour of the addons to make them look like part of the input its self.
.input-group .form-control {
border-left: 0;
border-right: 0;
}
.input-group-addon {
background: #fff;
}
Using bootsrap 4.6 I was able to get the border around the input-group-prepend and input-group-append with the following CSS:
.was-validated:invalid .input-group-prepend .input-group-text,
.was-validated:invalid .input-group-append .input-group-text
{
border-color: red;
}

CSS - Transition on border not working fine

The CSS code:
.css3_nudge ul li a {
-webkit-transition-property: color, background-color, padding-left, border-right;
-webkit-transition-duration: 400ms, 400ms, 400ms, 400ms;
}
.css3_nudge ul li a:hover {
background-color: #efefef;
color: #333;
padding-left: 50px;
border-right: 1px solid red;
}
The HTML code:
<div class="css3_nudge nudge">
<ul>
<li>Home</li>
<li>Blog</li>
<li>About</li>
<li>Register</li>
<li>Contact</li>
</ul>
</div>
The transition is working fine for all elements but border, it just appears at the end of 400ms, there is no effect on border.
What I'm trying to achieve is a effect like the new google gmail buttons.
Thanks in advance for any help
This is a pretty simple fix. You just need a border to already exist before the hover effect. So just set the border-right: 1px solid #fff; like below:
.css3_nudge ul li a {
-webkit-transition-property: color, background-color, padding-left, border-right;
-webkit-transition-duration: 400ms, 400ms, 400ms, 400ms;
border-right: 1px solid #fff; /* added property */
}
Then the transition is effectively just changing the colour of the border instead of creating a border.

Resources