I want to remove textbox outline in bootstrap 4 but its not working. How can I remove this line?
CSS
#content #main-content input[type=text]{
border: 0;
border: 1px solid #ccc;
height: 40px;
padding-left: 10px;
outline: 0;
}
html
<div class="form-group">
<label for="title">Title <span>*</span></label>
<input type="text" class="form-control" id="title" name="title" placeholder="Enter Title">
</div>
You can add the shadow-none Bootstrap class to remove the focus outline:
<div class="form-label-group">
<input type="password" id="inputPassword" class="form-control shadow-none" placeholder="Password" required>
<label for="inputPassword">Password</label>
</div>
The theme you're using sets box-shadow to inset 0 -2px 0 #2196F3 on focus.
You need to override it, but not with none, because that would just remove it. You probably want it to remain at same value like when it's not focused. In short, you need this:
textarea:focus,
textarea.form-control:focus,
input.form-control:focus,
input[type=text]:focus,
input[type=password]:focus,
input[type=email]:focus,
input[type=number]:focus,
[type=text].form-control:focus,
[type=password].form-control:focus,
[type=email].form-control:focus,
[type=tel].form-control:focus,
[contenteditable].form-control:focus {
box-shadow: inset 0 -1px 0 #ddd;
}
Also note you need to load this CSS after Bootstrap CSS and the theme you're loading.
As the accepted answer works it isn't the best option.
You could simply override the input/button outline by editing the variables. (As the question specifically asks for bootstrap 4)
If you override the Bootstrap 4 variables like so. You could use the following code to disable all focus outlines:
$input-btn-focus-box-shadow: none;
$input-btn-focus-width: 0;
For only disabling the button focus outline use the follow code:
$btn-focus-box-shadow: none;
This you could also be done for indicators, select, dropdown etc. Just search the default variables list of bootstrap 4
EDIT
Also works for v5: Github variables
Even though you can disable the focus outline, it isn't a best practice. Conform the web accessibility keyboard standards a site should be useable by tabbing. By disabling the CSS you disable this functionality.
To separate these users there is a new pseudo class: :focus-visible which you can use however it's not compatible everywhere yet. Chromium changelog
You have to remove your box-shadow on input:focus.
Write this css in your custom css file below the bootstrap css to override. It will be good practice if you use your custom parent class.
.parent-class .form-group input[type=text]:focus,
.parent-class .form-group [type=text].form-control:focus, {
box-shadow: none;
}
This is better and shorter:
input[type="text"], textarea {
outline: none;
box-shadow:none !important;
border:1px solid #ccc !important;
}
A very simple solution would be like this,
form .form-control:focus{
border-color: #0d6efd;
box-shadow: none;
}
we overwrite the .form-control bootstrap class.
I was facing the same issue I solved it using this trick in such a way that we don't have to think about importing CSS after bootstrap or something like that.
Note: #0d6efd is the color I wanted to give to my input element when it gets focused.
Using a box-shadow will not completely hide the outline in the button, and it doesn't work on inputs, text-boxes and other form controls...
Using the shadow-none will may have a slight and thin border, but it is much better than the former solution...Here's the code if you need assistance:
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<form action="/search" method="get">
<center class="container">
<div class="input-group mb-3">
<input type="text" class="form-control shadow-none" placeholder="Search the web" aria-label="Username" aria-describedby="basic-addon1" required name="q" autocomplete="off">
<input type="submit" class="btn input-group-text shadow-none" id="basic-addon1" value="search">
</div>
</center>
</form>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js"></script>
If you are theming in scss
$input-btn-focus-box-shadow: none;
The below code just worked for me now and I sure do hope it helps somebody else too ..
.form-group input:focus{
outline:0px !important;
box-shadow: none !important;
}
This one line, taken from #tao works when adding a css style:
The inset, however, should be zero. (It will create a weird line in the latest Bootstrap 4.)
<input type="radio" style="box-shadow: inset 0 0 0 #ddd;">
'shadow-none' is not working anymore.
You just have to add
box-shadow: none
on focus event in CSS.
For example.
.box_style:focus{
border:none;
box-shadow:none;
}
Try the !important property in any css code. That will not overwrite other css.
Try this:
//for normal text box
input[type=text]{
border: 0 !important;
height: 40px;
padding-left: 10px;
outline: 0 !important;
}
//for selected/active text box
input[type=text]:focus{
border: 0 !important;
outline: 0 !important;
}
//for hovered text box
input[type=text]:hover{
border: 0 !important;
outline: 0 !important;
}
Add this on input: focus
-webkit-box-shadow: none;
box-shadow: none;
outline: -webkit-focus-ring-color auto 0px;
background-color: rgb(250,250,250);
As far as I see from your css, you set the border to 0 then again to 1. Replace it as below
#content #main-content input[type=text]{
border: 1px solid #ccc;
border: 0;
height: 40px;
padding-left: 10px;
outline: 0;
}
Related
Input checkbox outline in Chrome behaves itself really odd.
Generally, outline doesn't include margins, but when you set the focus on it with the keyboard (! not the mouse), it starts including margins. For the tag types other than input (as well, as for the other input type) everything works fine (outline never includes margins). In Firefox everything works fine as well.
Here is the JsFiddle to test this:
.error input {
outline: 2px solid #c00;
margin: 2px;
}
.error input[type=checkbox] {
outline: 2px solid #c00;
}
<div class="error">
<input type='checkbox'><label>Some label</label>
<input type='text'>
</div>
http://jsfiddle.net/71ybetjv/
Is this a Chrome bug? And is there any workaround for that?
Chromes default :focus-visible style contains outline-offset: 2px;.
This can be overwritten: (Though it's worth noting that you should replace it with another clear "focused" style for accessibility)
.error input {
outline: 2px solid #c00;
margin: 2px;
}
.error input:focus-visible {
outline-offset: 0;
}
.error input[type=checkbox] {
outline: 2px solid #c00;
}
<div class="error">
<input type='checkbox'><label>Some label</label><br />
<input type='text' />
</div>
I am trying to customize my input forms, but something strange is happening and I can't understand why it is happening.
Here is my HTML:
<input type="text" class="multi-choice" >
<input type="text" class="multi-choice" >
<input type="text" class="multi-choice" >
As you can see I have three input element with a "multi-choice" class.
This is the CSS I made just for testing:
.multi-choice {
background-color: red;
height: 400px;
width: 10px;
border: 10px solid black;
outline: none;
}
What's happening is that CSS is only being applied on background-color and height resulting in huge red input bars. However it is completely ignoring width, border and outline.
When I do the same thing using id instead of class it is working correctly. Why it is happening?
EDIT
According to the answers the code works, so I assume it is something on my pc that is preventing it to work somehow.
I guess everything is working fine with your html and css. Maybe you could not realize your border because you did not give different color
.multi-choice {
background-color: red;
height: 200px;
width: 200px;
border: 10px solid black;
outline: none;
}
<input type="text" class="multi-choice" >
<input type="text" class="multi-choice" >
<input type="text" class="multi-choice" >
The border instruction requires more. Just saying 10px isn't enough.
border: 10px solid black;
Will work better.
I'm running into an issue where the default blue outline when input fields are focused is not being removed despite trying two CSS techniques to remove the outline. I have tried to use input:focus and input[type="text"]:focus, but neither are removing this outline. What am I possibly doing wrong with my CSS?
Here is my form with the comment-box input:
<div class="comment-form">
<form action="/app/blog/{{this.blogId}}/comment" method="post">
<label for="data-comment">Comment:</label>
<br />
<input type="text" name="comment" class="comment-box">
<button type="submit" class="comment-submit">Comment</button>
</form>
</div>
Here is the CSS (input.comment-box CSS is working):
input.comment-box {
width: 80%;
box-sizing: border-box;
border: 2px solid #D8D8D8;
border-radius: 4px;
}
.comment-box input:focus {
border: 2px solid #D8D8D8;
outline: none !important;
}
.comment-box input:focus means an input box inside the .comment-box class, i.e.,
<div class="comment-box">
<input type="text">
</div>
What you probably want is:
input.comment-box:focus {
outline: none;
}
or just
.comment-box:focus {
outline: none;
}
The problem is with the selector .comment-box input:focus. That will target input:focus inside of .comment-box, which doesn't exist.
The selector either needs to be .comment-box:focus or input:focus or .comment-form input:focus
For this case, input should always come first > class/id > pseudo-class.
input.comment-box:focus {
outline: none;
}
Otherwise
.comment-form input:focus {
outline: none;
}
I can't tell you why it's not working in this case, but I will suggest that you think carefully and read http://www.outlinenone.com/ before you actually remove the outline. It exists so that someone who is not using a mouse can navigate among form inputs and determine which one has focus. It appears that your styles will remove ANY distinction between the focused and unfocused input box. Essentially, this means you are excluding numerous people with disabilities from using your website.
I am using bootstrap's input-group on a textarea, what I want is to have the label, or input-group-addon above the textarea, but due to the styling of the 'addon' element it doesn't look very good (especially on the right side).
How can I make the textarea look decent, using input-group?
Example to see difference on <input> and <textarea>
I guess what I'd like is slightly rounded edges on the right side, like the one on the left, on the textarea input, the normal input is fine.
You can override the regular add-on by adding a new class to the textarea and apply some css changes on it:
<div class="input-group-addon textarea-addon"> Description </div>
<textarea class="form-control" rows="5"></textarea>
and for the css:
.textarea-addon{
border-bottom-left-radius: 0px !important;
border-top-right-radius: 4px !important;
border:1px solid #ccc !important;
border-bottom: none !important;
}
textarea{
border-top-left-radius:0px !important;
border-top-right-radius:0px !important;
}
If your'e using less or compass I'd use variables instead of plain numbers.
In addition, you should add some browser compatibility properties (such as -webkit and -moz prefixes)
Live example: http://plnkr.co/edit/dMa4UPLMqOXdVITzFKNr?p=preview
How about this:-
.row .form-group .input-group-addon {
background-color: #eee;
border-right: 1px solid #ccc;
border-top-right-radius: 4px;
border-bottom-left-radius: 0;
border-bottom: 0;
}
.row .form-group textarea.form-control {
border-top-right-radius: 0px;
border-top-left-radius: 0px;
margin-top: 0px;
margin-bottom: 0px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet" />
<div class="row" style="padding:30px 100px;">
<div class="col-md-6">
<div class="form-group">
<div class="input-group-addon">Description</div>
<textarea class="form-control" rows="5"></textarea>
</div>
</div>
</div>
the default style for this element is not expected to have the right not rounded corners when placed before the input field and has rounded corners to the left when it is placed after the left field .. you can add them this way or create a class with these features Included and add the Element
The input-group- addon default style don
<span class="input-group-addon"
style=" border-top-right-radius: 6px;
border-bottom-right-radius: 6px; border-right: solid 1px #ccc;">
Description</span>
use span and not div for addon
I created a search box:
<form>
<input type="search" class="search" placeholder="Search...">
</form>
The search button seems to have some kind of default inner shadow which I'd like to remove. This is how my CSS looks:
form
{
float: right;
}
.search
{
box-shadow: none;
padding: 6px 14px 6px 30px;
margin-top: 16px;
background: url(../images/search.png) no-repeat 8px 6px;
}
The "box-shadow: none;" doesn't work, I also tried the "box-shadow: 0 0 0 0;" but that doesn't work either. How can I remove the shadow? Thank you in advance.
Update: Don't do this. The outline is good for accessibility.
Try outline: 0. I think that you may also simply be referring to the default border. Try updating the border to whatever is desirable such as 1px solid black
http://jsfiddle.net/smZPy/