I have a button that I'd like to customize differently than what I've set the global buttons. I added the button and modified it but there is no option for editing the hover color of the button so I am trying to write additional CSS for it.
I set up a new class for the button
Custom-Button-Orange-to-Purple
but when I try to add the additional styling to this element (I did try and set up the class without the :hover and that didn't work either).
.Custom-Button-Orange-to-Purple:hover {
background-color:#8601AF !important;
border-color:none !important;
}
The button I'm trying to modify is the orange one at the bottom of the page here: Kidz Haven Daycare . The code changes the border of the button to purple which I don't want.
I'm new to adding custom CSS (obviously) and would be grateful for some help!
This is what your CSS looks like, which is absolutely wrong:
.wp-block-button:hover .Custom-Button-Orange-to-Purple:hover has-custom-font-size:hover {
border-radius:8px;
background-color:#8601AF !important;
}
Also, there is no element with the class Custom-Button-Orange-to-Purple.
This is what I understand from your question: You have customized the style of usual buttons, and now you want to style a button which should look different. If so, this may help:
.btn-default {
width: 100px;
}
.btn-default:hover {
background-color: skyblue;
color: #fff;
}
.btn-special:hover {
background-color: purple;
color: #fff;
font-weight: bold;
}
<button class="btn-default">Normal Button</button>
<button class="btn-default">Normal Button</button>
<button class="btn-default btn-special">Special Button</button>
This took a full days worth of hunting and trying different methods. What I did was to get rid of the class name I had added to the "Advanced" tab where I created the custom button. Instead I added HTML to the block on the page where the button would appear. I used a div container as well to be able to center it on the page.
HTML added to the block with new class names:
<div class="Center-Aligned-Custom-Button-Orange-to-Purple">
WHY KIDS HAVEN DAYCARE
ADDITIONAL CSS:
.Center-Aligned-Custom-Button-Orange-to-Purple {
display:flex;
justify-content:center;
align-items:center;
}
.Custom-Button-Orange-to-Purple {
border-radius:8px !important;
font-family:Roboto !important;
font-size:15px !important;
font-weight:500 !important;
line-height: 25px !important;
padding-left: 15px!important;
padding-right: 15px!important;
padding-top: 1px !important;
padding-bottom: 1px !important;
text-align: center !important;
background-color: #FB9902 !important;
color: #fff !important;
position: absolute !important!;
}
I'm not certain if I "needed" to use the !important but given the amount of time it took to figure this out, I figured it was better safe than sorry!
Thanks for the responses. I'm a total newbie, so some comments were over my
The code in my stylesheet I used to change the color of a selected button isn't working. The hover function works but it won't keep the color after being selected.
My code is below. I don't know enough about CSS to really troubleshoot all that much.
body .btn:hover,
body .MS_contentWrapper_inner .PaymentPartSubmitButton:hover,
body .MS_contentWrapper_inner [id*='AddProgramDailyAdmissionToCart']:hover,
input[type="submit"]:hover,
.BBFormSubmitButton:hover,
#anchorOtherDates:hover,
#anchorOtherTimes:hover,
.Programming_Event_AlternateDatesCaption:hover,
.Programming_Event_AlternateTimesCaption:hover {
background: #E77229 !important;
color: #fff;
text-decoration: none;
border: none !important;
}
body .btn:active,
body .MS_contentWrapper_inner .PaymentPartSubmitButton:active,
body .MS_contentWrapper_inner [id='AddProgramDailyAdmissionToCart']:active,
input[type="submit"]:active,
.BBFormSubmitButton:active,
#anchorOtherDates:active,
#anchorOtherTimes:active,
.Programming_Event_AlternateDatesCaption:active,
.Programming_Event_AlternateTimesCaption:active {
background: #E77229 !important;
color: #fff;
text-decoration: none;
border: none !important;
}
The top half of the code works great but the second half changes nothing.
If you really need the color to stay after you clicked the button you need to set the style dynamically on click. I suggest using a css class for this which you can use to set any style you want.
Example:
HTML:
<input type="submit">
CSS:
.active {
background-color: deeppink;
color: white;
border: none;
}
JS:
document.querySelector('input[type="submit"]').addEventListener('click', (e) => {
e.target.classList.add('active');
});
I am trying to add custom css style to my caldera forms on a wordpress website.
what i am trying to achieve is to add a hover style to my fields of radio checklist
Right now i was only able to add style to the bullets ,I am currently stuck with adding a hover style to the fields
this is the link to the form
https://purdywordy.com/order-here/
This is the CSS that i have used
.caldera-grid input[type=checkbox]:hover,
.caldera-grid input[type=radio]:hover {
cursor: pointer;
}
input[type=radio]:before,
input[type=checkbox]:before {
font-family: FontAwesome !important;
font-size: px;
}
input[type=radio]:before {
content: '\f111';
border-radius: 50%;
padding: 0px 15px 0px 0px;
}
input[type=checkbox]:before {
content: '\f14a';
color: red;
background: red;
border-radius: 3px;
padding: 2px;
}
input[type=radio]:checked:before {
color: red;
}
When inspected, your form (HTML) is structured like this:
<div class="radio">
<label>
<input type="radio">
</label>
</div>
Since you have used nested input inside of a label, you don't even need for/id attributes, but I am guessing that is automatically generated by the form. Btw, do you have control over the structure of HTML or the proposed form simply spits it out?
For your current structure, you could style it like this:
.radio:hover > label {
/* add the style for the label */
}
.radio:hover input[type="radio"] {
/* add the style for the radio button */
}
Whatever you need to apply the style to, "listen" for a hover on the parent and then target its direct children. You get the point.
EDIT: My bad. I have said that input is nested inside of label. Therefore, radio:hover > input will not target it. Omit the > and it will target any input inside div with the class .radio. Sorry for the possible confusion. You can learn more about CSS selectors and differences between them here.
This should work. Your radio buttons and labels sit inside a class of 'radio'. You can remove the .form-group reference here unless there are other places on the page that you don't want this styling to apply to.
.form-group .radio:hover {
cursor: pointer;
background-color: grey;
border: 2px solid blue;
border-radius: 5px;
// other hover properties
}
I added this but still the blue outline appear when the button is clicked.
.btn:focus {
outline: none;
}
how to remove that ugly thingy?
May be your properties are getting overridden.
Try attaching !important to your code along with the :active .
.btn:focus,.btn:active {
outline: none !important;
box-shadow: none;
}
Also add box-shadow because otherwise you will still see the shadow around button.
Although this isn't a good practise to use !important I suggest you use more specific class and then try applying the css with the use of !important...
There are built-in boostrap class shadow-none for disabling box-shadow (not outline) (https://getbootstrap.com/docs/4.1/utilities/shadows/). This removes shadow of button:
<button class='btn btn-primary shadow-none'>Example button</button>
Update: docs link for bootstrap 5: https://getbootstrap.com/docs/5.1/utilities/shadows/, and for beta: https://getbootstrap.com/docs/5.2/utilities/shadows/
In the latest version of Bootstrap, I found removing outline itself doesn't work. And I have to add this because there is also a box-shadow:
.btn:focus, .btn:active {
outline: none !important;
box-shadow: none !important;
}
Try Below Code
.button:active,
button:active,
.button:focus,
button:focus,
.button:hover,
button:hover{
border:none !important;
outline:none !important;
}
This was happening to me in Chrome (though not in Firefox). I've found out that the outline property was being set by Bootstrap as outline: 5px auto -webkit-focus-ring-color;. Solved by overriding the outline property later in my custom CSS as follows:
.btn.active.focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn:active:focus, .btn:focus {
outline: 0;
}
this will solve button with a text, button only a icon or a button is a link:
<!--1. button with a text -->
<button type="button" class="btn btn-success" id="newWord">Save</button>
<!--2. button only with a close icon -->
<button type="button" class="close"></button>
<!--3. button is a link -->
<a class="btn btn-success btn-xs" href="#">Save</a>
button,
button:active,
button:focus,
button:hover,
.btn,
.btn:active,
.btn:focus,
.btn:hover{
outline:none !important;
}
if you add border:none !important;
{
border:none !important;
outline:none !important;
}
then the button will become smaller size when clicked.
In Bootstrap 4 they use
box-shadow: 0 0 0 0px rgba(0,123,255,0); on :focus, so i solved my problem with
a.active.focus,
a.active:focus,
a.focus,
a:active.focus,
a:active:focus,
a:focus,
button.active.focus,
button.active:focus,
button.focus,
button:active.focus,
button:active:focus,
button:focus,
.btn.active.focus,
.btn.active:focus,
.btn.focus,
.btn:active.focus,
.btn:active:focus,
.btn:focus {
outline: 0;
outline-color: transparent;
outline-width: 0;
outline-style: none;
box-shadow: 0 0 0 0 rgba(0,123,255,0);
}
Try this
.btn
{
box-shadow: none;
outline: none;
}
The SCSS way for all elements (not only buttons):
body {
* {
&:focus, &.focus,
&:active, &.active {
outline: transparent none 0 !important;
box-shadow: 0 0 0 0 rgba(0,123,255,0) !important;
-webkit-box-shadow: none !important;
}
}
}
This may help if someone still has this question unresolved.
(function() {
$('button').on('click', function() {
$("#action").html("button was clicked");
console.log("the button was clicked");
});
})();
.btn-clear {
background-color: transparent !important;
border-style: none !important;
cursor: pointer;
}
.btn-clear:active,
.btn-clear:focus {
outline-style: none !important;
outline-color: transparent;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- this button has default style -->
<button>Action</button>
<!-- this button is clear of style -->
<button class="btn-clear">Action</button>
<label id="action"></label>
I just had the same issue and the following code worked for me:
.btn:active, .btn:focus, .btn:active:focus, .btn.active:focus {
outline: none !important;
}
.btn {
margin:32px;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<button type="button" class="btn btn-default">Button</button>
Hoping it will help!
You need to use proper nesting and then apply styles to it.
Right click on button and find the exact class nesting for it using (Inspect element using firebug for firefox), (inspect element for chrome).
Add style to whole bunch of class. Only then it would work
I found this quite useful in my case after the button click.
$('#buttonId').blur();
I opted to simply remove the border width on :focus. This removes the ugly space between the outline and the button's rounded corners. For some reason this issue only happens on actual button elements and not <a class="btn"> elements.
button.btn:focus {
border-width: 0;
}
Sometimes {outline: 0} didn't solve the problem and we can try {box-shadow: none;}
Here's my Boostrap 4 solution to remove the button outline
/*
* Boostrap 4
* Remove blue outline from button
*/
.btn:focus,
.btn:active {
box-shadow: none;
}
Actually in bootstrap is defined all variables for all cases. In your case you just have to override default variable '$input-btn-focus-box-shadow' from '_variables.scss' file. Like so:
$input-btn-focus-box-shadow: none;
Note that you need to override that variable in your own custom '_yourCusomVarsFile.scss'. And that file should be import in project in first order and then bootstrap like so:
#import "yourCusomVarsFile";
#import "bootstrap/scss/bootstrap";
#import "someOther";
The bootstraps vars goes with flag '!default'.
$input-focus-box-shadow: $input-btn-focus-box-shadow !default;
So in your file, you will override default values.
Here the illustration:
$input-focus-box-shadow: none;
$input-focus-box-shadow: $input-btn-focus-box-shadow !default;
The very first var have more priority then second one. The same is for the rest states and cases.
Hope it will help you.
Here is '_variable.scss' file from repo, where you can find all initials values from bootstrap: https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss
Chears
Even after removing the outline from the button by setting its value to 0, There is still a funny behaviour on the button when clicked, its size shrinks a bit. So i came up with an optimal solution:
.btn:focus {
outline: none !important;
box-shadow: 0 0 0 0;
}
Hope this helps...
How to avoid border focus on click of bootstrap buttons:
.btn-secondary:not(:disabled):not(.disabled).active:focus, .btn-secondary:not(:disabled):not(.disabled):active:focus, .show>.btn-secondary.dropdown-toggle:focus {
box-shadow: none;
}
.btn.focus, .btn:focus {
outline: 0;
box-shadow: none;
}
How to avoid border focus on click of bootstrap input fields:
.form-control.focus, .form-control:focus {
outline: 0;
box-shadow: none;
}
If this doesn't work for your specific case, then I suggest you to open the inspector page, click on the selector tool (small arrow in a box in the top-left corner) click on the element you are trying to edit, then click again on the same element and look at the "Styles" tab to see what changes in terms of CSS... search something related to "focus" and you should be able to detect the code you have to overwrite in your CSS. Hope this is helpful.
a:focus {
outline: none;
}
this works for me on BS3
This one worked for me in Bootstrap 4:
.btn {border-color: transparent;}
Try
.btn-primary:focus {
box-shadow: none !important;
}
Keep in mind, if you're button is inside of an anchor like:
<a href='some_link'>
<button class='btn'>Button</button>
</a>
Adding the style to the button itself may not be enough, you may need to add the a:focus, a:active { outline: none } CSS rules where appropriate (this worked for me).
Try the below
.bootstrap-select .dropdown-toggle:focus
{
outline: 0 !important;
}
I'm using bootstrap 4, you can use outline and box-shadow.
#buttonId {
box-shadow: none;
outline: none;
}
Or if the button is inside an element like a div without back-ground, box-shadow is enough.
#buttonId {
box-shadow: none;
}
Example: https://codepen.io/techednelson/pen/XRwgRB
If you are using version 4.3 or higher, your code will not work properly.
This is what I used. It worked for me.
.btn:focus, .btn:active {
outline: none !important;
box-shadow: none !important;
-webkit-box-shadow: none !important;
}
Instead to target on button class (.btn), here I target to button element itself and it works for me.
button:focus {
outline:none !important;
box-shadow:none !important;
}
And can use shadow-none class for input field
You can add below answer to your _variable.scss file, no need to change the other outline or any thing. I'm sure this will work.
$btn-active-box-shadow: none !important;
For Check box and radio buttons
.form-check-input:checked ,.form-check-input:focus,.form-check-input:active {
outline: none !important;
box-shadow: 0 0 0 0 rgba(0,123,255,0) !important;
-webkit-box-shadow: none !important;
}
Here's a non-CSS method. Using JQuery, simply remove the "focus" class whenever the element is has been clicked.
$(".btn").mousemove(function(element) {
$(this).removeClass("focus");
});
This method may cause the border to flash into existence and then back out briefly, which doesn't look bad in my opinion (it looks like part of the response when the button is clicked).
The reason I used .mousemove() is that .click() and .mouseup() both proved to be ineffective.