Does anyone know the how to change Bootstrap\'s input:focus
? The blue glow that shows up when you click on an input
field?
Simple one
To remove it:
.form-control, .btn {
box-shadow: none !important;
outline: none !important;
}
To change it
.form-control, .btn {
box-shadow: new-value !important;
outline: new-value !important;
}
Add an Id to the body tag. In your own Css (not the bootstrap.css) point to the new body ID and set the class or tag you want to override and the new properties. Now you can update bootstrap anytime without loosing your changes.
html file:
<body id="bootstrap-overrides">
css file:
#bootstrap-overrides input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, input[type="url"]:focus, textarea:focus{
border-color: red;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(126, 239, 104, 0.6);
outline: 0 none;
}
See also: best way to override bootstrap css
For the input border before the focus. You can specify your favorite color you want to use and other css like padding etc
.input {
padding: 6px 190px 6px 15px;
outline: #2a65ea auto 105px ;
}
When we focus on input. You can specify your favorite color outline you wish
.input:focus{
box-shadow: none;
border-color: none;
outline: lightgreen auto 5px ;
}
For Bootstrap v4.0.0 beta release you will need the following added to a stylesheet that overrides Bootstrap (either add in after CDN/local link to bootstrap v4.0.0 beta or add !important
to the stylings:
.form-control:focus {
border-color: #6265e4 !important;
box-shadow: 0 0 5px rgba(98, 101, 228, 1) !important;
}
Replace the border-color and the rgba on the box-shadow with which ever colour style you'd like*.
Actually, in Bootstrap 4.0.0-Beta (as of October 2017) the input element isn't referenced by input[type="text"], all Bootstrap 4 properties for the input element are actually form based.
So it's using the .form-control:focus styles. The appropriate code for the "on focus" highlighting of an input element is the following:
.form-control:focus {
color: #495057;
background-color: #fff;
border-color: #80bdff;
outline: none;
}
Pretty easy to implement, just change the border-color property.
In Bootstrap 3.3.7 you can change the @input-border-focus value in the Forms section of the customizer: