Pretty new to CSS and i just want to change the defualt outline colour of a button. I beleive im using bootstrap
So far i can change the button colour when the mouse hovers over it, and also the default text colour but not the outline
Ive tried this
.btn-outline-info{
color: #ea4335;
outline-color: #ea4335;
}
the color part works but the outline-color does not
Any help would be appreciated thanks
Try border-color
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
.btn-outline-info {
color: blue;
border-color: red;
}
.btn-outline-info:hover {
color: green;
border-color: purple;
}
</style>
<button class="btn btn-outline-info">Info</button>
I think you need to add an outline style. For example,
outline-style: solid;
outline-color: #92a8d1;
.btn:active {
outline-color: red;
}
:active is when the button is being hovered
This adds the outline style and color on focus:
.btn-outline-info:focus {
outline-style: solid;
outline-color: #ea4335;
}
In CSS it's important to remember that like in HTML and javascript, the computer won't do what you want it to do, it only does what it has to do. It doesn't know what the CSS property outline-colour is, so it does nothing.
Do make an outline of a button, you use border-color: (color). Or you could add a specified border using, border: 3px solid green; there are many changes you can make with borders. To have a full explanation, head to the W3 schools site. https://www.w3schools.com/cssref/pr_border.asp
And then on hover, you could do this,
button:hover {
border: 2px dotted blue;
color: purple;
}
Also In the future, this kind of question doesn't need a whole discussion on stack overflow, it can be easily researched and troubleshooted!
Cheers
Related
This question already has answers here:
How to remove the border highlight on an input text element
(21 answers)
Closed 7 years ago.
Can anyone explain how to remove the orange or blue border (outline) around text/input boxes? I think it only happens on Chrome to show that the input box is active. Here's the input CSS I'm using:
input {
background-color: transparent;
border: 0px solid;
height: 20px;
width: 160px;
color: #CCC;
}
This border is used to show that the element is focused (i.e. you can type in the input or press the button with Enter). You can remove it with outline property, though:
textarea:focus, input:focus{
outline: none;
}
You may want to add some other way for users to know what element has keyboard focus though for usability.
Chrome will also apply highlighting to other elements such as DIV's used as modals. To prevent the highlight on those and all other elements as well, you can do:
*:focus {
outline: none;
}
⚠️ Accessibility warning
Please notice that removing outline from input is an accessibility bad practice. Users using screen readers will not be able to see where their pointer is focused at. More info at a11yproject
The current answer didn't work for me with Bootstrap 3.1.1. Here's what I had to override:
.form-control:focus {
border-color: inherit;
-webkit-box-shadow: none;
box-shadow: none;
}
input:focus {
outline:none;
}
This will do. Orange outline won't show up anymore.
<input style="border:none" >
Worked well for me. Wished to have it fixed in html itself ... :)
I've found the solution.
I used: outline:none; in the CSS and it seems to have worked. Thanks for the help anyway. :)
this remove orange frame in chrome from all and any element no matter what and where is it
*:focus {
outline: none;
}
Solution
*:focus {
outline: 0;
}
PS: Use outline:0 instead of outline:none on focus. It's valid and better practice.
Please use the following syntax to remove the border of text box and remove the highlighted border of browser style.
input {
background-color:transparent;
border: 0px solid;
height:30px;
width:260px;
}
input:focus {
outline:none;
}
Set
input:focus{
outline: 0 none;
}
"!important" is just in case. That's not necessary. [And now it's gone. –Ed.]
This will definitely work. Orange outline will not show anymore..
Common for all tags:
*:focus {
outline: none;
}
Specific to some tag, ex: input tag
input:focus {
outline:none;
}
I found out that you can also use:
input:focus{
border: transparent;
}
When I click somewhere else the border disappears, I tried to use onfocus: none, but that didn't help. How to make this ugly button border disappear when I click on it?
input[type=button] {
width: 120px;
height: 60px;
margin-left: 35px;
display: block;
background-color: gray;
color: white;
border: none;
}
<input type="button" value="Example Button">
Using outline: none; you can remove that border in chrome.
<style>
input[type=button] {
width: 120px;
height: 60px;
margin-left: 35px;
display: block;
background-color: gray;
color: white;
border: none;
outline: none;
}
</style>
Focus outline in Chrome and FF:
removed button focus outline:
button,
input[type=button] {
outline: none;
}
button::-moz-focus-inner,
input[type=button]::-moz-focus-inner {
border: 0;
}
/*
Accessibility (A11Y)
Don't forget! User accessibility is important
*/
button:focus,
input[type=button]:focus {
/* your custom focused styles here */
}
It works for me simply :)
*:focus {
outline: 0 !important;
}
This one worked for me
button:focus {
border: none;
outline: none;
}
Set both the outline and the box-shadow properties of the button to none and make them important.
input[type=button] {
outline: none !important;
box-shadow: none !important;
}
The reason for setting the values to **important** is that, if you are using other CSS libraries or frameworks like Bootstrap, it might get overridden.
The outline property is what you need. It's shorthand for setting each of the following properties in a single declaration:
outline-style
outline-width
outline-color
You could use outline: none;, which is suggested in the accepted answer. You could also be more specific if you wanted:
button {
outline-style: none;
}
button:focus{outline:none !important;}
add !important if it is used in Bootstrap
To avoid the problem caused when you change the outline property on a focus, is to give a visual effect when the user Tab on the input button or click on it.
In this case is a submit type, but you can apply to a type="button" too.
input[type=submit]:focus {
outline: none !important;
background-color: rgb(208, 192, 74);
}
Given the html below:
<button class="btn-without-border"> Submit </button>
In the css style do the following:
.btn-without-border:focus {
border: none;
outline: none;
}
This code will remove button border and will disable button border focus when the button is clicked.
As many others have mentioned, selector:focus {outline: none;} will remove that border but that border is a key accessibility feature that allows for keyboard users to find the button and shouldn't be removed.
Since your concern seems to be an aesthetic one, you should know that you can change the color, style, and width of the outline, making it fit into your site styling better.
selector:focus {
outline-width: 1px;
outline-style: dashed;
outline-color: red;
}
Shorthand:
selector:focus {
outline: 1px dashed red;
}
It's greatly simple than you think. When the button is focussed, apply the outline property, like this:
button:focus {
outline: 0 !important;
}
But when I use none value, it doesn't work for me.
Removing nessorry accessible event not a good idea in up to standard web developments.
either way if you looking for a solution removing just the outline doesn't solve the problem. you also have to remove the blue color shadow. for specific scenarios use a separate class name to isolate the this special style to your button.
.btn.focus, .btn:focus {
outline: 0;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, .25);
}
Better do this
.remove-border.focus, .remove-border:focus {
outline: 0;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, .25);
}
Removing the outline is an accessibility nightmare. People tabbing using keyboards will never know what item they're on.
Best to leave it, as most clicked buttons will take you somewhere anyway, or if you HAVE to remove the outline then isolate it a specific class name.
.no-outline {
outline: none;
}
Then you can apply that class whenever you need to.
Another alternative to restore outline when using the keyboard is to use :focus-visible. However, this doesn't work on IE :https://caniuse.com/?search=focus-visible.
It's also good note that outline: none can be applied to both <button> tags and input[type=button] to remove the browser-applied border on click.
Since Chrome and Mozilla added this line not only around buttons but also around linked text, I use on my site this:
a:focus {outline: none;
}
Works for both browsers, links, and buttons.
Btw, this did not (27.4.2021):
input[type=button]{
outline:none;
}
input[type=button]::-moz-focus-inner {
border: 0;
}
I have two buttons on my web page which look as follows...
The button on the left has the correct style border; thin and with no rounded corners.
The button on the right, which currently has focus, does not have the correct style border. When Inspecting the element within chrome, it has the following properties...
element.style {
position: absolute;
bottom: 25px;
border: none !important;
right: 140px;
}
.btn:focus {
border-radius: 0px;
}
.btn-primary.focus, .btn-primary:focus {
color: #fff;
background-color: #286090;
}
.btn.focus, .btn:focus, .btn:hover {
text-decoration: none;
}
.btn.active.focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn:active:focus, .btn:focus {
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
I would have thought that applying the border: none !important css property (while the element was forced into a focus state would have worked, but apparently not.
Furthermore, even when I set the border-color to yellow while the button is focused, this effect is not applied.
How can I prevent the border from being rounded off, so that it stays square and the corners remain a 90 degree angle?
What you see as an outline.
Just add this line to the button's css:
outline: none !important;
The purpose of the outline is accessabilty, so you should think carefully about removing it. You can always change the way the border looks instead.
As for !important, if you write your css right, you shouldn't use it. Inline css (style='color: blue') supercedes classes and id styling, so in your case the !important might be redundant.
There will be a lot of suggestions to remove the outline.
Before You decide to do so, please note that it'a a really bad practice from the accesibility point of view
https://medium.com/better-programming/a11y-never-remove-the-outlines-ee4efc7a9968
I'm using materializecss for my project but I have a problem.
I have disabled the outline of the inputs but the inputs still showing up a weird outline on focus.
This is the css for the inputs
.inputs input[type=text]:focus {
border: 1px solid #FFFFFF!important;
background-color: #FAFAFA!important;
box-shadow: none!important;
outline:none!important;
}
This is likely the :active pseudo class as it seems like the border is changing when you click.
Try making a rule that changes both the focus and active pseudo classes.
.inputs input[type=text]:active,
.inputs input[type=text]:focus {
border: 1px solid #FFFFFF!important;
background-color: #FAFAFA!important;
box-shadow: none!important;
outline:none!important;
}
I don't see a question here, but I am assuming you want to get rid of the outline altogether?
If you provide more details I'll be able to give more accurate answer, but first thing that comes to mind from looking at provided gif is that maybe that outline comes from an :active state.
You can remove outline for both states on the bare element and see if that has some impact:
input:focus,
input:active {
outline: none;
}
If this didn't solve your problem, please give some more input (pun intended :)) and we'll figure it out.
Best,
N.
P.S. Upon further inspection, it seems to me that when you click, the border is set. That's also why your input fields move a little bit (can you see that)? Please update your code. This should be trivial.
I am looking for a way to enlarge the distance between the text and underline on my pages. i use mainly CSS but i had to use tags as well, basicly my question considers both cases. is there a way to change this spacing? the code is pretty simple:
.title_span {
font-weight: bold;
text-decoration: underline;
color: grey;
}
my other posibility is try somehow use background for the span using 1px picture and repeat against X axis i am looking for cleaner solution.
Not without tricks, no. One simple solution is to wrap the text in another span and give that a bottom border.
<span class="underline"><span class="title_span">title of something</span></span>
.title_span {
font-weight: bold;
text-decoration: underline;
color: grey;
}
.underline {
padding-bottom: 2px;
border-bottom: grey 1px solid;
}
http://jsfiddle.net/m9RQ9/
spacing between text and underline its No, but you could go with something like border-bottom: 1px solid #000 and padding-bottom: 3px.
edit: if you want the same color of the "underline" (which in my example is a border), you just leave out the color declaration, i.e. border-bottom-width: 1px and border-bottom-style: solid.
I'm afraid this isn't possible per se, but what you can do is apply a border-bottom as an alternative to background-image