Firefox 中的输入字段在没有焦点的情况下发光

mob*_*emk 2 css firefox sass cross-browser

我遇到了一个只影响 Firefox 的奇怪问题。除了 reCAPTCHA 小部件中的一个特定字段外,所有表单字段都按照我的预期显示(也就是说,具有 1 像素的细边框,根据输入值的当前验证状态改变颜色)直到添加文本。请注意,这是此表单中唯一具有此效果的字段,它不是来自我的任何样式——我已经检查了计算样式,没有什么可以解释的。

问题截图

我已经申请outline: 0px none transparent;-moz-appearance: none;到没有成功这个元素。想法?

萨斯:

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%);
    }
}
Run Code Online (Sandbox Code Playgroud)

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"><a href="http://www.google.com/recaptcha" title="reCAPTCHA">Powered by reCAPTCHA</a></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>
Run Code Online (Sandbox Code Playgroud)

编辑:添加了 SASS 和相关的 HTML 来提问

mob*_*emk 5

Steven Don指出这是box-shadow我尝试添加box-shadow: none到所有输入和文本区域的效果之后,它覆盖了导致这种红色发光效果的默认 Firefox 样式。出于好奇,以下是导致效果的实际规则(来自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;
}
Run Code Online (Sandbox Code Playgroud)

由于它们来自浏览器样式表,因此即使使用基本元素选择器也很容易覆盖,这就是我在这里所做的。无论哪种方式,它都解决了这个特定的跨浏览器显示问题。