1

I am trying to extend Bootstrap. I do not want to touch any of the Bootstrap core files, so I have created my own styles.scss and in there I have the following:

@import "custom/variables";

@import "../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

@import "custom/modular-styles";

In _variables.scss I am overwriting some of the variables (e.g. getting rid of rounded corners).

In _modular-styles.scss I call various other SASS partials that I want to customise (e.g. _forms.scss).

In _forms.scss here is what I've done:

.form-control {
    display: block;
    width: 100%;
    height: $input-height-base;
    padding: $padding-base-vertical $padding-base-horizontal;
    font-size: $font-size-base;
    line-height: $line-height-base;
    color: $input-color;
    background-color: $input-bg;
    background-image: none;
    border: 1px solid $input-border;
    border-radius: $input-border-radius;
    box-shadow: none; // this use to be @include box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
    @include transition(border-color ease-in-out .15s, box-shadow ease-in-out .15s);
    outline: none; // this use to be @include form-control-focus;

    @include placeholder;

    &::-ms-expand {
        border: 0;
        background-color: transparent;
    }

    &:focus {
        outline: none;
    }

    &[disabled],
    &[readonly],
    fieldset[disabled] & {
        background-color: $input-bg-disabled;
        opacity: 1;
    }

    &[disabled],
    fieldset[disabled] & {
        cursor: $cursor-disabled;
    }
}

Shouldn't that work? Yet I am still seeing the outline glow when an input is on :focus

halfer
  • 19,824
  • 17
  • 99
  • 186
J86
  • 14,345
  • 47
  • 130
  • 228
  • I would start by asking whether you really should? I know it's nice for you to have your website look consistent on all browsers, but this isn't good for the user. A user who always uses Chrome should get a consistent "Chromey" experience across all sites. – Rik Lewis Jan 26 '17 at 13:56
  • @RikLewis Regardless, Bootstrap already modifies the default behavior of textboxes. – Quangdao Nguyen Jan 26 '17 at 14:13

5 Answers5

4

The glow on focus in Bootstrap is given by a box-shadow on :focus, like this:

.form-control:focus {
    border-color: #66afe9;
    outline: 0;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102,175,233,.6);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102,175,233,.6);
}

If you want to modify your focus styles add sth like this:

.form-control {

  &:focus {
     box-shadow: none;
     /* your new styles */
  }

}
Daniel Sixl
  • 2,488
  • 2
  • 16
  • 29
3

You can do it by overriding the sass variables:

$input-box-shadow: none;
$input-focus-box-shadow: none;
$input-btn-focus-box-shadow: none;

And in case that doesn't do the trick (I've seen some weird behaviors with files ordering):

.form-control {
  &:focus {
    box-shadow: none !important;
  }
}

Just a hint, but make sure you've imported Bootstrap only once. Once I had forgotten to remove it from my angular.json (former angular-cli.json) and that caused conflicts.

user5365075
  • 2,094
  • 2
  • 25
  • 42
0

Try adding the following CSS:

textarea:hover, 
input:hover, 
textarea:active, 
input:active, 
textarea:focus, 
input:focus,
button:focus,
button:active,
button:hover,
label:focus,
.btn:active,
.btn.active
{
    outline: none !important;
    border: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    box-shadow: none !important;
}
Syden
  • 8,425
  • 5
  • 26
  • 45
  • Yep I think I am. My `_forums.scss` sits within `_modular-styles.scss` and that is loaded **after** I load the Bootstrap stuff – J86 Jan 26 '17 at 14:10
0

From what I recall, you need to override the outline in the :focus pseudo class, not just the main css class

.form-control {
    ...
    &:focus {
        outline: none;
    }
}

See: How to remove the border highlight on an input text element

Community
  • 1
  • 1
noggin182
  • 627
  • 4
  • 14
0

Try adding the following css

.form-control:focus {
  box-shadow: none;
}

Explanation: In Bootstrap, the value of box-shadow changed when the input tag is focused, so the transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out worked.

Hope it helps.

J.Wang
  • 101
  • 1
  • 4