CSS hover rule not showing on element inspection [closed] - css

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 months ago.
Improve this question
I am trying to make a simple button that changes appearance when clicked, in a toggle fashion. I use a class defining the general appearance of the button (.button), a class defining the base look of this specific button (.hire) and a class defining the changes when the button has been clicked once (.hired).
I use JS to add the .hired class and everything works perfectly until I hover over the button. The .hired class is added and the default rule for that class is applied. However, the .hired:hover rule isn't applied and doesn't even show up when I inspect the element, when the other hover rules are there.
I am genuinely confused as to what could be causing this one hover rule to be utterly ignored.
Here's the CSS:
.button {
color: white;
font-size: 16px;
font-weight: bold;
background: rgb(202, 67, 1);
border: none;
border-radius: 5px;
padding: 10px;
transition: background .2s;
}
.button:hover {
background: rgb(138, 46, 1);
cursor: pointer;
}
.hire {
position: absolute;
top: 15px;
right: 15px;
line-height: 32px;
text-align: center;
width: 100px;
border: 2px solid rgb(202, 67, 1);
transition: border .2s;
}
.hire:hover{
border: 2px solid rgb(138, 46, 1);
}
.hired {
background-color: transparent;
color: rgb(202, 67, 1);
transition: color .2s;
}
.hired:hover {
background: rgba(0, 0, 0, 0);
color: rgb(138, 46, 1);
}
EDIT: I eventually found a solution, although I didn't fix the issue. Copying the hover rule in a separate style section in the HTML head instead of importing it did the trick. However I still don't understand what the underlaying issue was and it is definitely still there, hidden behind my hack.

The CSS hover rules are not applied on element inspection in Chrome (at least for me). This might be a bug in Chrome. Apparently, the rules are applied when you edit the CSS file and re-upload it. So, in order to check CSS hover rules, upload your CSS file and edit the file, then re-upload it and also :hover pseudo-class doesn't work in the inspector. This means that, for example, if you are trying to use hover on an element to change its background color, you won't see the results of that on the element's inspector. The element's background will be the same color as its regular, non- :hover background.
You can also try this
-add display: block in your CSS rule. This will set the position to block and the element will then be positioned relative to the block it is in.

everything works perfectly until I hover over the button.
The .hired class is added and the default rule for that class is
applied.
However, the .hired:hover rule isn't applied
I had a go at reproducing your setup - and it looks like it works fine and that you've done everything correctly.
Please ask in the comments below if you have any further questions.
Working Example:
const hireButton = document.querySelector('.hire.button');
const clickHireButton = (e) => {
e.target.classList.add('hired');
}
hireButton.addEventListener('click', clickHireButton, false);
.button {
color: white;
font-size: 16px;
font-weight: bold;
background: rgb(202, 67, 1);
border: none;
border-radius: 5px;
padding: 10px;
transition: background .2s;
}
.button:hover {
background: rgb(138, 46, 1);
cursor: pointer;
}
.hire {
position: absolute;
top: 15px;
right: 15px;
line-height: 32px;
text-align: center;
width: 100px;
border: 2px solid rgb(202, 67, 1);
transition: border .2s;
}
.hire:hover{
border: 2px solid rgb(138, 46, 1);
}
.hired {
background-color: transparent;
color: rgb(202, 67, 1);
transition: color .2s;
}
.hired:hover {
background: rgba(0, 0, 0, 0);
color: rgb(138, 46, 1);
}
<button class="hire button" type="button" />Click Me</button>

Related

How to change the minimize, maximize, and close background colors button using gtk.css file?

I have been modifying the gtk.css file and managed to change the look of mi windows. For the most part i have been able to figure what certain components i must modify to change the look of certain things. however I have not been able to find a way to modify the window's minimize, maximize, and close buttons certain properties and I have been trying for a good while now.
I was able to modify the background-image of the search button in my terminal as you can see in the picture to make it blend in into the headerbar color.
I was able to modify the color of the minimize, maximize, and close buttons color but I can't seem to figure out two remove the background color for these three buttons.
I used the following to modify the regular buttons properties.
button{
/* min-height: 0px;
min-width: 0px;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;*/
/* border: 1px pink; */
/*border-radius: 0px; */
transition: all 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
color: blue;
outline-color: rgba(229, 112, 132, 0.7);
border-color: pink;
background-image: image(pink);
text-shadow: 0 1px rgba(255, 255, 255, 0.769231);
-gtk-icon-shadow: 0 1px rgba(255, 255, 255, 0.769231); }
I used the following to change the close and others buttons colors as well, But i can't make the background color disappear.
button.minimize, button.maximize, button.close{
color: blue;
border:0px;
border-radius: 0px;
border-color: pink;
background-image: image(pink);
background-color: pink;
border-radius: 0px;
}
I used all the following components but i just can't seem to make it work, I used one by one, they are not all active at once. These modify the color but won't modify the background color like it did with the search button or menu button from the terminal.
headerbar .close{
color:yellow;
}
.tab-close-button{
color:red;
}
button.titlebutton.minimize{
color: red;
background-color: pink;
background-image: :image(pink);
}
button.headerbutton.minimize{
color: red;
background-color: pink;
background-image: image(pink);
}
button.header.minimize{
color: yellow;
background-color: pink;
background-image: :image(pink);
}
I know its been 3 months since this post but I have an answer.
Even if you had already found it, might as well send it for those coming from google.
windowcontrols button image:not(:hover) {
background-color: transparent;
}

CSS utility library overrides my button style?

I'm trying to style a button by writing my own css but also using Tailwind for other styles.
My code for the button is as follows but some of the elements are crossed out.
button {
margin-left: 10px; /*crossed out*/
padding: 5px 25px; /*crossed out*/
background-color: rgba(2,68,62,1); /*crossed out*/
border: none;
border-radius: 10px;
cursor: pointer; /*crossed out*/
transition: all 0.3s ease 0s;
}
Is it because Tailwind already has default values for button? I know using !important is bad practice so how do I fix this? My html for the cta button is:
<a class="cta" href="#"><button>CONTACT</button></a>
If I reference .cta in my css, I can't change the actual CONTACT text; I wanted to use text-decoration: none.
I did set a * at the top of my css.
* {
box-sizing: border-box;
margin: 0;
padding: 0;
background-color: #b3b3b4;
}

ngx-international-phone-number to cant added style

Im used my angular project for this ngx-international-phone-number, I tried to add style, but its not worked for me, anyone know how to add correctly css on this input
Look my image, button and input filed is not aligned
StackBlitz here
<international-phone-number class="mystyle form-control form-control-sm" placeholder="Enter phone number" [maxlength]="20" [defaultCountry]="'us'" name="phone_number" [allowedCountries]="['in', 'ca', 'us']"></international-phone-number>
css
.mystyle .dropbtn {
background: #2196f3;
color: white;
border: none;
cursor: pointer;
}
.mystyle .form-control {
display: block;
width: 100%;
padding: 0.4375rem 0;
font-size: 1rem;
line-height: 1.5; margin: 0px 5px;
color: #495057;
background-color: rgba(0, 0, 0, 0);
background-clip: padding-box;
border: none;
border-radius: 0;
box-shadow: none;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
You need add :host ::ng-deep { *your css* } before your style.
And change app.component.css > app.component.scss
https://stackblitz.com/edit/angular-add-style
Hope it helps you.
You can use ng-phone-number instead of ngx-international-phone-number, its basically an extension of ngx-international-phone-number but its updated and well maintained with language support and issues fixed quickly upon feedback. Flag issues is also fixed here.
Here is the link of library https://www.npmjs.com/package/ng-phone-number

CSS :hover Selector not working as expected with gifs

I am working on a new button styles and currently facing a challenge: my <button> CSS :hover selector is not behaving as expected.
All attempts to making it work have proven futile.
How can I possibly achieve that effectively?
Below is my code:
.button_depression {
background: url(http://67.media.tumblr.com/tumblr_m9atx55D6F1qd1e6no1_400.gif)
no-repeat;
border: 0;
color: #ffffff;
padding: 5px 35px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
cursor: pointer;
border-radius: 5px;
font-family: Times New Roman;
transition-duration: 0.5s;
}
.button_depression:hover {
background-color: #959595;
}
Simply use background for your hover; not background-color as illustrated in the snippet below:
.button_depression:hover {
background: #959595;
}
Brief summary:
background CSS property is a shorthand to set the values for one or more of: background-clip, background-color, background-image, background-origin, background-position, background-repeat, background-size, and background-attachment.
When working without the shorthand, the background-image property supersedes background-color and as such, setting background-color alone without abnegating it (background-image) will result in its precedence.
In other words, background-image: none; in combination with background-color: #959595; will work. (Refer to snippet below)
.button_depression:hover {
background-color: #959595;
background-image: none;
}
(background-image: unset; works well too, but can't tell if supported by all browsers)
Note that you can be achieved the same, using the background shorthand, simply as above, with background: #959595; (which I prefer: simple, less verbose, same result).
More details here ....
You can't see the button hover changing the background color due to the background image. You can set the button image to None on hover and then change the color. This might be what you want. Alternatively you can just set background to the background color you wanted. Your preference how you want to acomplish this.
.button_depression {
background: url(http://67.media.tumblr.com/tumblr_m9atx55D6F1qd1e6no1_400.gif) no-repeat;
border: 0px;
color: #ffffff;
padding: 5px 35px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
cursor: pointer;
border-radius: 5px;
font-family: Times New Roman;
transition-duration: 0.5s;
}
.button_depression:hover {
background: None;
background-color: #959595;
}

Stop Twitter Bootstrap from overriding custom css for buttons

I'm using Twitter Bootstrap for a Rails 3.2.3 project and I'm importing each stylesheet in my application.css.scss file. I'm customizing a page in the static folder (with a render file that's in a different folder) with the static.css.scss file that is above bootstrap files in the application file. I'm trying to make the button different from the normal btn class. My code is:
.btn.signup {
margin-top: 10px;
font-size: 18px;
padding: 10px 48px 10px;
background-color: rgb(255, 138, 22);
}
.btn.signup:hover {
margin-top: 10px;
font-size: 18px;
padding: 10px 48px 10px;
background-color: rgb(255, 138, 22);
}
However in Firefox, the button is still grey except for the outer edges which are the correct color. When I hover over the button, the lower half is orange. Inspecting the button, it shows:
.btn.signup:hover, li.signup.buttons:hover {
margin-top: 10px;
font-size: 18px;
padding: 10px 48px;
background-color: rgb(255, 138, 22);
}
button.btn, input.btn[type="submit"] {
}
.btn:hover, li.buttons:hover {
color: rgb(51, 51, 51);
text-decoration: none;
background-color: rgb(230, 230, 230);
background-position: 0px -15px;
-moz-transition: background-position 0.1s linear 0s;
}
.btn:hover, li.buttons:hover, .btn:active, li.buttons:active, .btn.active, li.active.buttons, .btn.disabled, li.disabled.buttons, .btn[disabled], li.buttons[disabled] {
background-color: rgb(230, 230, 230);
}
.btn.signup, li.signup.buttons {
margin-top: 10px;
font-size: 18px;
padding: 10px 48px;
background-color: rgb(255, 138, 22);
}
How do I make it so the entire button is orange? I'll change the hover color later but for now I want it all to be orange and not grey.
Not sure if you're still looking for help on this. Oh well...I guess I'll still pitch in my thoughts.
Do take note that the class .btn in Twitter Bootstrap actually has a background image attached to it, to generate the somewhat subtle gradient effect.
The gradient covers most of the button's background, so your selected background colour only shows at the edges.
This gradient is also why you partially see your own background colour when you hover over the button - the -moz-transition causes that background image gradient to shift upwards (this is normally used to simulate a gradual darkening effect in the colour of the button when you hover over it). If you look closely, you can see that the top half of the button is coloured by the bottom of the gradient, and the bottom half is the background colour.
So you'll need to define either background-image: none; in your custom class, or better yet, define your own gradient so you don't lose that visual aesthetic. If you take the latter course of action, just remember to make the bottom colour of the gradient the same as your background-color, rgb(255, 138, 22). Otherwise, when you hover over the button, it will be quite clear where the gradient ends, and the background colour starts.

Resources